// $ANTLR 3.1.3 Mar 17, 2009 19:23:44 ttcn3tree.g 2009-04-30 09:53:56

package org.yatr.yatrc;

import java.util.HashMap;
import java.util.Map;
import java.util.LinkedList;
import java.util.LinkedHashMap;
import java.util.Iterator;
import static org.yatr.yatrc.Symtbl.*;
import static org.yatr.yatrc.Log.*;
import org.yatr.yatrc.TType.*;
import org.yatr.yatrc.*;


import org.antlr.runtime.*;
import org.antlr.runtime.tree.*;import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

import org.antlr.stringtemplate.*;
import org.antlr.stringtemplate.language.*;
import java.util.HashMap;
public class ttcn3tree extends TreeParser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "FUNC_CALL", "BLOCK", "UNARY_EXPR", "ACTUAL_ARGS", "FORMAL_ARGS", "FORMAL_VAR", "FIELD_ACCESS", "RUNS_ON", "PORT_REF", "SINGLE_CONNECT", "RCURLY", "LCURLY", "INT", "Cstring", "ID", "EscapeSequence", "WS", "COMMENT", "LINE_COMMENT", "'module'", "';'", "'control'", "'import'", "'from'", "'all'", "'type'", "'record'", "','", "'component'", "'integer'", "'charstring'", "'boolean'", "'const'", "':='", "'function'", "'('", "')'", "'return'", "'runs'", "'on'", "'testcase'", "'system'", "'var'", "'connect'", "':'", "'self'", "'mtc'", "'disconnect'", "'map'", "'unmap'", "'.'", "'start'", "'execute'", "'for'", "'if'", "'else'", "'log'", "'=='", "'!='", "'<'", "'<='", "'>'", "'>='", "'+'", "'-'", "'&'", "'*'", "'/'", "'mod'", "'true'", "'false'", "'create'"
    };
    public static final int T__42=42;
    public static final int ACTUAL_ARGS=7;
    public static final int T__28=28;
    public static final int T__57=57;
    public static final int T__23=23;
    public static final int T__51=51;
    public static final int T__47=47;
    public static final int T__69=69;
    public static final int T__73=73;
    public static final int Cstring=17;
    public static final int T__50=50;
    public static final int T__65=65;
    public static final int T__72=72;
    public static final int T__70=70;
    public static final int T__67=67;
    public static final int BLOCK=5;
    public static final int T__74=74;
    public static final int T__39=39;
    public static final int RCURLY=14;
    public static final int T__30=30;
    public static final int T__46=46;
    public static final int T__52=52;
    public static final int LCURLY=15;
    public static final int T__68=68;
    public static final int T__62=62;
    public static final int EscapeSequence=19;
    public static final int INT=16;
    public static final int T__27=27;
    public static final int FORMAL_ARGS=8;
    public static final int T__24=24;
    public static final int T__49=49;
    public static final int T__61=61;
    public static final int T__59=59;
    public static final int T__48=48;
    public static final int T__54=54;
    public static final int T__34=34;
    public static final int RUNS_ON=11;
    public static final int T__56=56;
    public static final int ID=18;
    public static final int T__35=35;
    public static final int T__36=36;
    public static final int FIELD_ACCESS=10;
    public static final int WS=20;
    public static final int T__58=58;
    public static final int FORMAL_VAR=9;
    public static final int T__64=64;
    public static final int T__44=44;
    public static final int T__66=66;
    public static final int COMMENT=21;
    public static final int T__33=33;
    public static final int LINE_COMMENT=22;
    public static final int UNARY_EXPR=6;
    public static final int T__55=55;
    public static final int T__45=45;
    public static final int T__29=29;
    public static final int SINGLE_CONNECT=13;
    public static final int PORT_REF=12;
    public static final int T__63=63;
    public static final int T__43=43;
    public static final int T__75=75;
    public static final int T__31=31;
    public static final int T__40=40;
    public static final int EOF=-1;
    public static final int T__53=53;
    public static final int FUNC_CALL=4;
    public static final int T__32=32;
    public static final int T__38=38;
    public static final int T__37=37;
    public static final int T__26=26;
    public static final int T__25=25;
    public static final int T__60=60;
    public static final int T__41=41;
    public static final int T__71=71;

    // delegates
    // delegators

    protected static class gBlockScope_scope {
        Symtbl symtbl;
        // for store StringTemplate definitions
        	//LinkedList st_localDef;
        //LinkedList st_localStatement;
    }
    protected Stack gBlockScope_stack = new Stack();


        public ttcn3tree(TreeNodeStream input) {
            this(input, new RecognizerSharedState());
        }
        public ttcn3tree(TreeNodeStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected StringTemplateGroup templateLib =
      new StringTemplateGroup("ttcn3treeTemplates", AngleBracketTemplateLexer.class);

    public void setTemplateLib(StringTemplateGroup templateLib) {
      this.templateLib = templateLib;
    }
    public StringTemplateGroup getTemplateLib() {
      return templateLib;
    }
    /** allows convenient multi-value initialization:
     *  "new STAttrMap().put(...).put(...)"
     */
    public static class STAttrMap extends HashMap {
      public STAttrMap put(String attrName, Object value) {
        super.put(attrName, value);
        return this;
      }
      public STAttrMap put(String attrName, int value) {
        super.put(attrName, new Integer(value));
        return this;
      }
    }

    public String[] getTokenNames() { return ttcn3tree.tokenNames; }
    public String getGrammarFileName() { return "ttcn3tree.g"; }



    String moduleName;
    HashMap<String, Symtbl> symtblOfModules;

    /* for structed type like record/set start */
    List<String> allStructedTypeList;

    /* for structed type like record/set end */

    /* for function define start */
    boolean isInFunctionDef=false;
    String  currentFuncName=null;
    TType currentFuncReturnType = null;
    StringTemplate  currentFuncReturnTypeST=null;
    /* for function define end */

    /* for statementBlockDef start */
    boolean isInStatementBlock=false;
    /* for statementBlockDef end */

    /* for component start */
    String runsOnComp=null;
    String runsOnSystem=null;
    StringTemplate startTCInstance=null;	//  if component1.start(func()) then  startTCInstance = component1
    /* for component end */

    /* for control part start */
    boolean isInControlPart=false;
    /* for control part end */


    TType getTypeOfModule(String moduleName, String typeName, Token token, TAttrib tattrib, TSubAttribTYPE tsubattrib){
    	/*
    	 * Find in MODULE space
    	 * TODO: Handle Multi-define in Multi-modules
    	 */
    	Symtbl symtblOfModule = symtblOfModules.get(moduleName);
    	if(symtblOfModule == null) {
    	    logError(token, "!!Undefined module name=%s", moduleName);
    	    return null;
    	}
    	
    	TType t = symtblOfModule.findType(typeName, tattrib, tsubattrib);
    	/*if(t == null) {
    	    logError(token, "!!Undefined type=%s in module%s", typeName, moduleName);
    	    return null;
    	}*/
    	return t;
    }

    TType getRecord(String moduleName, String recordName, Token token){
    	TType t = getTypeOfModule(moduleName, recordName, token, TAttrib.TYPE, TSubAttribTYPE.RECORD);
    	if(t == null) {
    	    logError(token, "!!Undefined record=%s in module%s", recordName, moduleName);
    	    return null;
    	}
    	return t;
    }

    TType getComponent(String moduleName, String componentName, Token token) {
    	TType t = getTypeOfModule(moduleName, componentName, token, TAttrib.TYPE, TSubAttribTYPE.COMPONENT);
    	if(t == null) {
    	    logError(token, "!!Undefined component=%s in module%s", componentName, moduleName);
    	    return null;
    	}
    	return t;
    }

    //get the type define like:   type integer INT;
    //the subTypeName and token referenced to INT
    TType getSubTypeDef(String moduleName, String subTypeName, Token token) {
    	TType t = getTypeOfModule(moduleName, subTypeName, token, TAttrib.TYPE, null);
    	if(t == null) {
    	    logError(token, "!!Undefined subType name=%s in module%s", subTypeName, moduleName);
    	    return null;
    	}
    	return t;
    }

    /**
     * token: then filed of component componentName
     */
    TType getFieldOfComponent(String moduleName, String componentName, Token token){
    	//TType t2 = getType(moduleName, token, TAttrib.TYPE, TSubAttribTYPE.COMPONENT);
    	/*
    	 * Find in MODULE space
    	 * TODO: Handle Multi-define in Multi-modules
    	 */
    	Symtbl symtblOfModule = symtblOfModules.get(moduleName);
    	if(symtblOfModule == null) {
    	    logError(token, "!!Undefined module name=%s", moduleName);
    	    return null;
    	}
    	
    	//get the component that defined in module	
    	TType t2 = symtblOfModule.findType(componentName, TAttrib.TYPE, TSubAttribTYPE.COMPONENT);
    	if(t2 == null) {
    	    logError(token, "!!Undefined component=%s in module%s", componentName, moduleName);
    	    return null;
    	}
    	
    	///
    	//System.out.println("t2.subtableItem "+token.getText()+":"+ t2.getSubTableItem(token.getText()));
    	//System.out.println("t2="+t2);
    	return t2.getSubTableItem(token.getText());
    }

    /**
     * If find token in Symbol table, return true if token redefined, otherwise return false.
     * NOTE: The return TType depended on the TAttrib attribute of token
     */
    boolean checkIsDefined(String moduleName, Token token) {
        /* find in local scope */
        TType typeReturn;
        for(int level = gBlockScope_stack.size()-1; level >=0; --level) {
    		Symtbl symtbl = ((gBlockScope_scope)gBlockScope_stack.elementAt(level)).symtbl;
    		typeReturn = symtbl.findType(token, null, null);
    		if(typeReturn != null) {
    		    emitRedefinedError(token, typeReturn.getToken());
    			return true;
    		}
    	}
    	
    	/* find in module scope */
    		/*
    	 * Find in MODULE space
    	 * TODO: Handle Multi-define in Multi-modules
    	 */
    	Symtbl symtblOfModule = symtblOfModules.get(moduleName);
    	if(symtblOfModule == null) {
    	    return false;
    	}
    	typeReturn = symtblOfModule.findType(token, null, null);
    	if(typeReturn == null) {
    	    return false;
    	}
    	emitRedefinedError(token, typeReturn.getToken());
        return true;
    }

    private void emitRedefinedError(Token t1, Token t2) {
        logError(t1, "Token \"%s\" multi-definitions.", t1.getText());
        if(t2!=null) {
            logError(t2, "This is the previous define.");
        }
    }

    /**
     * 1. Find token in all of the statementBlocks; if not find, go 2;
     * 2. find it in the symtblOfModules;
     */
    TType getType(String moduleName, Token token, TAttrib attrib, TSubAttrib subattrib) {
    	TType typeReturn;
    	/*
    	 * Find in local space
    	 */
    	for(int level = gBlockScope_stack.size()-1; level >=0; --level) {
    		Symtbl symtbl = ((gBlockScope_scope)gBlockScope_stack.elementAt(level)).symtbl;
    		typeReturn = symtbl.findType(token, null, null);
    		if(typeReturn != null) {
    		    if(attrib != null && typeReturn.getAttrib() != attrib) {
    		        logError(token, "Expecting type=%s but %s", attrib, typeReturn.getAttrib());
    		        return null;
    		    }
    			return typeReturn;
    		}
    	}
    	
    	/*
    	 * Find in MODULE space
    	 * TODO: Handle Multi-define in Multi-modules
    	 */
    	Symtbl symtblOfModule = symtblOfModules.get(moduleName);
    	if(symtblOfModule == null) {
    	    logError(null, "Undefined module name=%s", moduleName);
    	    return null;
    	}
    	typeReturn = symtblOfModule.findType(token, null, null);
    	if(typeReturn == null) {
    	    logError(token, "Undefined token=%s", token.getText());
    	    return null;
    	}
    	
        if(attrib != null && typeReturn.getAttrib() != attrib) {
            logError(token, "Expecting type=%s but %s", attrib, typeReturn.getAttrib());
            return null;
    	}
    	
    	return typeReturn;
    }

    /**
     * In boolean expression, we create a new VALUE object represent the BOOLEAN type.
     */
    TType doE1E2Bool(Token opToken, TType e1, TType e2, Object... exprExpectTYPEs) {
        TType typeVALUE = doE1E2(opToken, e1, e2, exprExpectTYPEs);
        if(typeVALUE==null) {
            return null;
        }
        TType typeTYPE = newType(opToken, TSubAttribTYPE.BOOLEAN);
        return newValue(opToken, (TSubAttribVALUE)typeVALUE.getSubAttrib(), typeTYPE);
    }

    //e1 and e2 is TAttrib.VALUE
    TType doE1E2(Token opToken, TType e1, TType e2, Object... exprExpectTYPEs) {
        if(e1==null) {   // e2 == null for UNARY_EXPR
            logError(opToken, "e1==null fail.");
            return null;
        }
        
        if(e2 != null && (e1.getAttrib()!=e2.getAttrib())) {
            logError(opToken, "e1.type=%s != e2.type=%s", e1.getAttrib(), e2.getAttrib());
            return null;
        }
        if(e1.getAttrib()!= TAttrib.VALUE) {
            logError(opToken, "e1.type=%s != VALUE ", e1.getAttrib());
            return null;
        }
        
        int i=0;
        for(i=0; i<exprExpectTYPEs.length; ++i) {
            Object o = exprExpectTYPEs[i];
            if(!(o instanceof TSubAttribTYPE)) {
                logError(opToken, "Internal error, unexpected TYPE object");
                throw new RuntimeException("Internal error, unexpected TYPE object");
            }
            if( e1.getType().getSubAttrib() == ((TSubAttribTYPE)o) ) {
                break;
            }
        }
        if(i > 0 && i==exprExpectTYPEs.length) {
            logError(opToken, "Unexception TYPE=%s for \"%s\" operator.", e1.getType().getSubAttrib(), opToken.getText());
            return null;
        }
        
        if(e2==null)
            return e1;
        
        /*
         * Check the type compatibility. True if the type is obsolutely equal.
         */
        if(e1.getType().getSubAttrib() != e2.getType().getSubAttrib()) {
            logError(opToken, "e1.datatype=%s != e2.datatype=%s", 
                e1.getType().getSubAttrib(), e2.getType().getSubAttrib());
            return null;
        }
        
        if(e1.getSubAttrib() == TSubAttribVALUE.VAR) {
            return e1;
        }
        return e2;
    }

    /**
     * @param isConstInit true if constDef rule call this method, otherwise false.
     */
    void doAssignment(Token token, TType e1, TType e2, boolean isConstInit) {
        if(e1 == null || e2 == null) {
            logError(token, "Internal error: null pointer %s %s", 
                                              e1 == null, e2 == null);
        } else {
            if(isConstInit!=true && (e1.getSubAttrib() == TSubAttribVALUE.CONST) ) {
                logError(token, "Constant expression cannot be changed!");
            } else {
                if(e1.getType().getSubAttrib() != e2.getType().getSubAttrib()) {
                    logError(token, "Incompatible data type between %s and %s.",
                        e1.getType().getSubAttrib(), e2.getType().getSubAttrib());
                }
            }
        }
    }

    /**
     * Checks the compatibility between formal types and actual types.
     */
    boolean checkActualArg(Token token, Map<String, TType> argValueMap, LinkedList<TType> argValueList) {
        if(argValueMap == null) {
            if(argValueList.size() > 0) {
                logError(token, "The formal parameter's size=0 not equal with the actual parameter's size=%d.", argValueList.size());
                return false;
            }
            return true;
        }
        
        if( argValueMap.size() != argValueList.size()) {
            logError(token, "The formal parameter's size=%d not equal with the actual parameter's size=%d.",
                argValueMap.size(), argValueList.size());
            return false;
        }
       
        Iterator<String> iter = argValueMap.keySet().iterator();
        for(int i=0; i<argValueList.size(); ++i) {
            TType formalValue = argValueMap.get(iter.next());
            TType actualValue = argValueList.get(i);
            if(formalValue.getType().getSubAttrib() != actualValue.getType().getSubAttrib()) {
                logError(token, "The data type of argument %d not equal:%s vs %s", i, 
                    formalValue.getType().getSubAttrib(), actualValue.getType().getSubAttrib());
                return false;
            }
        }

        return true;
    }




    public static class ttcn3File_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "ttcn3File"
    // ttcn3tree.g:348:1: ttcn3File[HashMap<String, Symtbl> symtbl] : ttcn3Modules -> ttcn3File(testSuite=\"genttcn\"imports=importDefmodules=$ttcn3Modules.st_modules);
    public final ttcn3tree.ttcn3File_return ttcn3File(HashMap<String, Symtbl> symtbl) throws RecognitionException {
        ttcn3tree.ttcn3File_return retval = new ttcn3tree.ttcn3File_return();
        retval.start = input.LT(1);

        ttcn3tree.ttcn3Modules_return ttcn3Modules1 = null;



         symtblOfModules = symtbl;

        try {
            // ttcn3tree.g:355:3: ( ttcn3Modules -> ttcn3File(testSuite=\"genttcn\"imports=importDefmodules=$ttcn3Modules.st_modules))
            // ttcn3tree.g:355:5: ttcn3Modules
            {
            pushFollow(FOLLOW_ttcn3Modules_in_ttcn3File72);
            ttcn3Modules1=ttcn3Modules();

            state._fsp--;


            	    LinkedList<String> importDef=new LinkedList<String>();
                    importDef.add("org.etsi.ttcn.tci.*");
                    importDef.add("org.etsi.ttcn.tri.*");
                    importDef.add("org.yatr.tci.*");
                    importDef.add("static org.yatr.comm.Comm.*");
                    importDef.add("org.yatr.ttcn.rt.*");
                    importDef.add("org.yatr.ttcn.rt.impl.*");
                    importDef.add("org.yatr.ttcn.tci.*");
                    importDef.add("org.yatr.exception.*");
            	 


            // TEMPLATE REWRITE
            // 367:5: -> ttcn3File(testSuite=\"genttcn\"imports=importDefmodules=$ttcn3Modules.st_modules)
            {
                retval.st = templateLib.getInstanceOf("ttcn3File",
              new STAttrMap().put("testSuite", "genttcn").put("imports", importDef).put("modules", (ttcn3Modules1!=null?ttcn3Modules1.st_modules:null)));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "ttcn3File"

    public static class ttcn3Modules_return extends TreeRuleReturnScope {
        public List st_modules;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "ttcn3Modules"
    // ttcn3tree.g:371:1: ttcn3Modules returns [List st_modules] : ( (md+= ttcn3Module )+ | EOF );
    public final ttcn3tree.ttcn3Modules_return ttcn3Modules() throws RecognitionException {
        ttcn3tree.ttcn3Modules_return retval = new ttcn3tree.ttcn3Modules_return();
        retval.start = input.LT(1);

        List list_md=null;
        ttcn3tree.ttcn3Module_return md = null;
         md = null;
        try {
            // ttcn3tree.g:372:3: ( (md+= ttcn3Module )+ | EOF )
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==23) ) {
                alt2=1;
            }
            else if ( (LA2_0==EOF) ) {
                alt2=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 2, 0, input);

                throw nvae;
            }
            switch (alt2) {
                case 1 :
                    // ttcn3tree.g:372:5: (md+= ttcn3Module )+
                    {
                    // ttcn3tree.g:372:5: (md+= ttcn3Module )+
                    int cnt1=0;
                    loop1:
                    do {
                        int alt1=2;
                        int LA1_0 = input.LA(1);

                        if ( (LA1_0==23) ) {
                            alt1=1;
                        }


                        switch (alt1) {
                    	case 1 :
                    	    // ttcn3tree.g:372:6: md+= ttcn3Module
                    	    {
                    	    pushFollow(FOLLOW_ttcn3Module_in_ttcn3Modules121);
                    	    md=ttcn3Module();

                    	    state._fsp--;

                    	    if (list_md==null) list_md=new ArrayList();
                    	    list_md.add(md.getTemplate());


                    	    }
                    	    break;

                    	default :
                    	    if ( cnt1 >= 1 ) break loop1;
                                EarlyExitException eee =
                                    new EarlyExitException(1, input);
                                throw eee;
                        }
                        cnt1++;
                    } while (true);

                    retval.st_modules = list_md;

                    }
                    break;
                case 2 :
                    // ttcn3tree.g:373:5: EOF
                    {
                    match(input,EOF,FOLLOW_EOF_in_ttcn3Modules131); 

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "ttcn3Modules"

    protected static class ttcn3Module_scope {
        LinkedHashMap<Token,StringTemplate> typesDefLinkedMap;
        LinkedList<StringTemplate> runnableImpls;
        LinkedList<CallableBean> callableList;
    }
    protected Stack ttcn3Module_stack = new Stack();

    public static class ttcn3Module_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "ttcn3Module"
    // ttcn3tree.g:376:1: ttcn3Module : ^( 'module' id ( moduleDefinitionList )? ( moduleControlPart )? ) -> ttcn3Module(name=$id.textmoduleDefList=$moduleDefinitionList.sttypesDefMap=$ttcn3Module::typesDefLinkedMaprunnableImpls=$ttcn3Module::runnableImplsmoduleControlPart=$moduleControlPart.ststructedTypeList=allStructedTypeListcallableList=$ttcn3Module::callableListtoken=$id.tokendesc=\"Module define for \\\"\"+moduleName+\"\\\"\");
    public final ttcn3tree.ttcn3Module_return ttcn3Module() throws RecognitionException {
        ttcn3Module_stack.push(new ttcn3Module_scope());
        ttcn3tree.ttcn3Module_return retval = new ttcn3tree.ttcn3Module_return();
        retval.start = input.LT(1);

        ttcn3tree.id_return id2 = null;

        ttcn3tree.moduleDefinitionList_return moduleDefinitionList3 = null;

        ttcn3tree.moduleControlPart_return moduleControlPart4 = null;



            allStructedTypeList = new LinkedList<String>();
        	((ttcn3Module_scope)ttcn3Module_stack.peek()).typesDefLinkedMap = new LinkedHashMap<Token,StringTemplate>();
        	((ttcn3Module_scope)ttcn3Module_stack.peek()).runnableImpls = new LinkedList<StringTemplate>();
        	((ttcn3Module_scope)ttcn3Module_stack.peek()).callableList = new LinkedList<CallableBean>();

        try {
            // ttcn3tree.g:394:3: ( ^( 'module' id ( moduleDefinitionList )? ( moduleControlPart )? ) -> ttcn3Module(name=$id.textmoduleDefList=$moduleDefinitionList.sttypesDefMap=$ttcn3Module::typesDefLinkedMaprunnableImpls=$ttcn3Module::runnableImplsmoduleControlPart=$moduleControlPart.ststructedTypeList=allStructedTypeListcallableList=$ttcn3Module::callableListtoken=$id.tokendesc=\"Module define for \\\"\"+moduleName+\"\\\"\"))
            // ttcn3tree.g:394:5: ^( 'module' id ( moduleDefinitionList )? ( moduleControlPart )? )
            {
            match(input,23,FOLLOW_23_in_ttcn3Module157); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_id_in_ttcn3Module159);
            id2=id();

            state._fsp--;

            moduleName = (id2!=null?id2.text:null);
            // ttcn3tree.g:395:8: ( moduleDefinitionList )?
            int alt3=2;
            int LA3_0 = input.LA(1);

            if ( (LA3_0==26||LA3_0==29||LA3_0==36||LA3_0==38||LA3_0==44) ) {
                alt3=1;
            }
            switch (alt3) {
                case 1 :
                    // ttcn3tree.g:395:10: moduleDefinitionList
                    {
                    pushFollow(FOLLOW_moduleDefinitionList_in_ttcn3Module173);
                    moduleDefinitionList3=moduleDefinitionList();

                    state._fsp--;


                    }
                    break;

            }

            // ttcn3tree.g:396:8: ( moduleControlPart )?
            int alt4=2;
            int LA4_0 = input.LA(1);

            if ( (LA4_0==25) ) {
                alt4=1;
            }
            switch (alt4) {
                case 1 :
                    // ttcn3tree.g:396:10: moduleControlPart
                    {
                    pushFollow(FOLLOW_moduleControlPart_in_ttcn3Module187);
                    moduleControlPart4=moduleControlPart();

                    state._fsp--;


                    }
                    break;

            }


            match(input, Token.UP, null); 

            	        if(allStructedTypeList.size()==0) allStructedTypeList = null;
            	    


            // TEMPLATE REWRITE
            // 402:6: -> ttcn3Module(name=$id.textmoduleDefList=$moduleDefinitionList.sttypesDefMap=$ttcn3Module::typesDefLinkedMaprunnableImpls=$ttcn3Module::runnableImplsmoduleControlPart=$moduleControlPart.ststructedTypeList=allStructedTypeListcallableList=$ttcn3Module::callableListtoken=$id.tokendesc=\"Module define for \\\"\"+moduleName+\"\\\"\")
            {
                retval.st = templateLib.getInstanceOf("ttcn3Module",
              new STAttrMap().put("name", (id2!=null?id2.text:null)).put("moduleDefList", (moduleDefinitionList3!=null?moduleDefinitionList3.st:null)).put("typesDefMap", ((ttcn3Module_scope)ttcn3Module_stack.peek()).typesDefLinkedMap).put("runnableImpls", ((ttcn3Module_scope)ttcn3Module_stack.peek()).runnableImpls).put("moduleControlPart", (moduleControlPart4!=null?moduleControlPart4.st:null)).put("structedTypeList", allStructedTypeList).put("callableList", ((ttcn3Module_scope)ttcn3Module_stack.peek()).callableList).put("token", (id2!=null?id2.token:null)).put("desc", "Module define for \""+moduleName+"\""));
            }


            }


                allStructedTypeList = null;
            	//((ttcn3Module_scope)ttcn3Module_stack.peek()).typesDefLinkedMap = null;
            	//((ttcn3Module_scope)ttcn3Module_stack.peek()).runnableImpls = null;	//save the runnable java code that generated from ".start(func1(arg1,arg2,..))" ttcn3 code.
            	//((ttcn3Module_scope)ttcn3Module_stack.peek()).callableList =null;

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
            ttcn3Module_stack.pop();
        }
        return retval;
    }
    // $ANTLR end "ttcn3Module"

    public static class moduleControlPart_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "moduleControlPart"
    // ttcn3tree.g:411:1: moduleControlPart : ^(c= 'control' statementBlock[null] ) -> moduleControlPart(moduleControlStatements=$statementBlock.sttoken=$c.getToken()desc=\"Control part in module \\\"\"+moduleName+\"\\\"\");
    public final ttcn3tree.moduleControlPart_return moduleControlPart() throws RecognitionException {
        ttcn3tree.moduleControlPart_return retval = new ttcn3tree.moduleControlPart_return();
        retval.start = input.LT(1);

        CommonTree c=null;
        ttcn3tree.statementBlock_return statementBlock5 = null;



        isInControlPart=true;

        try {
            // ttcn3tree.g:418:5: ( ^(c= 'control' statementBlock[null] ) -> moduleControlPart(moduleControlStatements=$statementBlock.sttoken=$c.getToken()desc=\"Control part in module \\\"\"+moduleName+\"\\\"\"))
            // ttcn3tree.g:418:7: ^(c= 'control' statementBlock[null] )
            {
            c=(CommonTree)match(input,25,FOLLOW_25_in_moduleControlPart356); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_statementBlock_in_moduleControlPart358);
            statementBlock5=statementBlock(null);

            state._fsp--;


            match(input, Token.UP, null); 

                ((ttcn3Module_scope)ttcn3Module_stack.peek()).callableList.add(CallableBean.valueOf(moduleName, "control", "ControlComponent", null));
                


            // TEMPLATE REWRITE
            // 422:7: -> moduleControlPart(moduleControlStatements=$statementBlock.sttoken=$c.getToken()desc=\"Control part in module \\\"\"+moduleName+\"\\\"\")
            {
                retval.st = templateLib.getInstanceOf("moduleControlPart",
              new STAttrMap().put("moduleControlStatements", (statementBlock5!=null?statementBlock5.st:null)).put("token", c.getToken()).put("desc", "Control part in module \""+moduleName+"\""));
            }


            }


            isInControlPart=false;

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "moduleControlPart"

    public static class moduleDefinitionList_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "moduleDefinitionList"
    // ttcn3tree.g:425:1: moduleDefinitionList : (st+= moduleDefinition )+ -> moduleDefinitionList(moduleDefList=$st);
    public final ttcn3tree.moduleDefinitionList_return moduleDefinitionList() throws RecognitionException {
        ttcn3tree.moduleDefinitionList_return retval = new ttcn3tree.moduleDefinitionList_return();
        retval.start = input.LT(1);

        List list_st=null;
        ttcn3tree.moduleDefinition_return st = null;
         st = null;
        try {
            // ttcn3tree.g:426:3: ( (st+= moduleDefinition )+ -> moduleDefinitionList(moduleDefList=$st))
            // ttcn3tree.g:426:5: (st+= moduleDefinition )+
            {
            // ttcn3tree.g:426:5: (st+= moduleDefinition )+
            int cnt5=0;
            loop5:
            do {
                int alt5=2;
                int LA5_0 = input.LA(1);

                if ( (LA5_0==26||LA5_0==29||LA5_0==36||LA5_0==38||LA5_0==44) ) {
                    alt5=1;
                }


                switch (alt5) {
            	case 1 :
            	    // ttcn3tree.g:426:6: st+= moduleDefinition
            	    {
            	    pushFollow(FOLLOW_moduleDefinition_in_moduleDefinitionList409);
            	    st=moduleDefinition();

            	    state._fsp--;

            	    if (list_st==null) list_st=new ArrayList();
            	    list_st.add(st.getTemplate());


            	    }
            	    break;

            	default :
            	    if ( cnt5 >= 1 ) break loop5;
                        EarlyExitException eee =
                            new EarlyExitException(5, input);
                        throw eee;
                }
                cnt5++;
            } while (true);



            // TEMPLATE REWRITE
            // 427:5: -> moduleDefinitionList(moduleDefList=$st)
            {
                retval.st = templateLib.getInstanceOf("moduleDefinitionList",
              new STAttrMap().put("moduleDefList", list_st));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "moduleDefinitionList"

    public static class moduleDefinition_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "moduleDefinition"
    // ttcn3tree.g:430:1: moduleDefinition : ( typeDef | constDef -> {$constDef.st} | functionDef -> {$functionDef.st} | importDef | testcaseDef -> {$testcaseDef.st});
    public final ttcn3tree.moduleDefinition_return moduleDefinition() throws RecognitionException {
        ttcn3tree.moduleDefinition_return retval = new ttcn3tree.moduleDefinition_return();
        retval.start = input.LT(1);

        ttcn3tree.typeDef_return typeDef6 = null;

        ttcn3tree.constDef_return constDef7 = null;

        ttcn3tree.functionDef_return functionDef8 = null;

        ttcn3tree.testcaseDef_return testcaseDef9 = null;


        try {
            // ttcn3tree.g:431:3: ( typeDef | constDef -> {$constDef.st} | functionDef -> {$functionDef.st} | importDef | testcaseDef -> {$testcaseDef.st})
            int alt6=5;
            switch ( input.LA(1) ) {
            case 29:
                {
                alt6=1;
                }
                break;
            case 36:
                {
                alt6=2;
                }
                break;
            case 38:
                {
                alt6=3;
                }
                break;
            case 26:
                {
                alt6=4;
                }
                break;
            case 44:
                {
                alt6=5;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 6, 0, input);

                throw nvae;
            }

            switch (alt6) {
                case 1 :
                    // ttcn3tree.g:431:5: typeDef
                    {
                    pushFollow(FOLLOW_typeDef_in_moduleDefinition437);
                    typeDef6=typeDef();

                    state._fsp--;


                    	   if((typeDef6!=null?typeDef6.t:null)!=null) {
                    	   		if((typeDef6!=null?typeDef6.t:null).getToken()!=null){
                    	   			((ttcn3Module_scope)ttcn3Module_stack.peek()).typesDefLinkedMap.put((typeDef6!=null?typeDef6.t:null).getToken(), (typeDef6!=null?typeDef6.st:null));
                    	   		} else {
                    	   			logError(null, "typeDef: "+(typeDef6!=null?typeDef6.t:null).toString());
                    	   		}
                    	   }
                    	   

                    }
                    break;
                case 2 :
                    // ttcn3tree.g:441:5: constDef
                    {
                    pushFollow(FOLLOW_constDef_in_moduleDefinition455);
                    constDef7=constDef();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 441:18: -> {$constDef.st}
                    {
                        retval.st = (constDef7!=null?constDef7.st:null);
                    }


                    }
                    break;
                case 3 :
                    // ttcn3tree.g:442:5: functionDef
                    {
                    pushFollow(FOLLOW_functionDef_in_moduleDefinition469);
                    functionDef8=functionDef();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 442:18: -> {$functionDef.st}
                    {
                        retval.st = (functionDef8!=null?functionDef8.st:null);
                    }


                    }
                    break;
                case 4 :
                    // ttcn3tree.g:443:5: importDef
                    {
                    pushFollow(FOLLOW_importDef_in_moduleDefinition480);
                    importDef();

                    state._fsp--;


                    }
                    break;
                case 5 :
                    // ttcn3tree.g:444:5: testcaseDef
                    {
                    pushFollow(FOLLOW_testcaseDef_in_moduleDefinition490);
                    testcaseDef9=testcaseDef();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 444:17: -> {$testcaseDef.st}
                    {
                        retval.st = (testcaseDef9!=null?testcaseDef9.st:null);
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "moduleDefinition"

    public static class importDef_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "importDef"
    // ttcn3tree.g:447:1: importDef : ^( 'import' 'from' id 'all' ) -> importDef(id=$id.texttoken=$id.tokendesc=$text);
    public final ttcn3tree.importDef_return importDef() throws RecognitionException {
        ttcn3tree.importDef_return retval = new ttcn3tree.importDef_return();
        retval.start = input.LT(1);

        ttcn3tree.id_return id10 = null;


        try {
            // ttcn3tree.g:448:3: ( ^( 'import' 'from' id 'all' ) -> importDef(id=$id.texttoken=$id.tokendesc=$text))
            // ttcn3tree.g:448:6: ^( 'import' 'from' id 'all' )
            {
            match(input,26,FOLLOW_26_in_importDef509); 

            match(input, Token.DOWN, null); 
            match(input,27,FOLLOW_27_in_importDef511); 
            pushFollow(FOLLOW_id_in_importDef513);
            id10=id();

            state._fsp--;

            match(input,28,FOLLOW_28_in_importDef515); 

            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 449:6: -> importDef(id=$id.texttoken=$id.tokendesc=$text)
            {
                retval.st = templateLib.getInstanceOf("importDef",
              new STAttrMap().put("id", (id10!=null?id10.text:null)).put("token", (id10!=null?id10.token:null)).put("desc", input.getTokenStream().toString(
              input.getTreeAdaptor().getTokenStartIndex(retval.start),
              input.getTreeAdaptor().getTokenStopIndex(retval.start))));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "importDef"

    public static class typeDef_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "typeDef"
    // ttcn3tree.g:451:1: typeDef returns [TType t] : ^( 'type' typeDefBody ) -> {$typeDefBody.st};
    public final ttcn3tree.typeDef_return typeDef() throws RecognitionException {
        ttcn3tree.typeDef_return retval = new ttcn3tree.typeDef_return();
        retval.start = input.LT(1);

        ttcn3tree.typeDefBody_return typeDefBody11 = null;


        try {
            // ttcn3tree.g:452:2: ( ^( 'type' typeDefBody ) -> {$typeDefBody.st})
            // ttcn3tree.g:452:4: ^( 'type' typeDefBody )
            {
            match(input,29,FOLLOW_29_in_typeDef555); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_typeDefBody_in_typeDef557);
            typeDefBody11=typeDefBody();

            state._fsp--;


            match(input, Token.UP, null); 
            retval.t = (typeDefBody11!=null?typeDefBody11.t:null);


            // TEMPLATE REWRITE
            // 452:50: -> {$typeDefBody.st}
            {
                retval.st = (typeDefBody11!=null?typeDefBody11.st:null);
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "typeDef"

    public static class typeDefBody_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "typeDefBody"
    // ttcn3tree.g:454:1: typeDefBody returns [TType t] : ( structuredTypeDef -> {$structuredTypeDef.st} | subTypeDef -> {$subTypeDef.st});
    public final ttcn3tree.typeDefBody_return typeDefBody() throws RecognitionException {
        ttcn3tree.typeDefBody_return retval = new ttcn3tree.typeDefBody_return();
        retval.start = input.LT(1);

        ttcn3tree.structuredTypeDef_return structuredTypeDef12 = null;

        ttcn3tree.subTypeDef_return subTypeDef13 = null;


        try {
            // ttcn3tree.g:455:2: ( structuredTypeDef -> {$structuredTypeDef.st} | subTypeDef -> {$subTypeDef.st})
            int alt7=2;
            int LA7_0 = input.LA(1);

            if ( (LA7_0==30||LA7_0==32) ) {
                alt7=1;
            }
            else if ( (LA7_0==ID) ) {
                alt7=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 7, 0, input);

                throw nvae;
            }
            switch (alt7) {
                case 1 :
                    // ttcn3tree.g:455:4: structuredTypeDef
                    {
                    pushFollow(FOLLOW_structuredTypeDef_in_typeDefBody578);
                    structuredTypeDef12=structuredTypeDef();

                    state._fsp--;

                    retval.t = (structuredTypeDef12!=null?structuredTypeDef12.t:null);


                    // TEMPLATE REWRITE
                    // 455:52: -> {$structuredTypeDef.st}
                    {
                        retval.st = (structuredTypeDef12!=null?structuredTypeDef12.st:null);
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:456:4: subTypeDef
                    {
                    pushFollow(FOLLOW_subTypeDef_in_typeDefBody590);
                    subTypeDef13=subTypeDef();

                    state._fsp--;

                    retval.t = (subTypeDef13!=null?subTypeDef13.t:null);


                    // TEMPLATE REWRITE
                    // 456:38: -> {$subTypeDef.st}
                    {
                        retval.st = (subTypeDef13!=null?subTypeDef13.st:null);
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "typeDefBody"

    public static class structuredTypeDef_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "structuredTypeDef"
    // ttcn3tree.g:458:1: structuredTypeDef returns [TType t] : ( recordDef -> {$recordDef.st} | componentDef -> {$componentDef.st});
    public final ttcn3tree.structuredTypeDef_return structuredTypeDef() throws RecognitionException {
        ttcn3tree.structuredTypeDef_return retval = new ttcn3tree.structuredTypeDef_return();
        retval.start = input.LT(1);

        ttcn3tree.recordDef_return recordDef14 = null;

        ttcn3tree.componentDef_return componentDef15 = null;


        try {
            // ttcn3tree.g:459:2: ( recordDef -> {$recordDef.st} | componentDef -> {$componentDef.st})
            int alt8=2;
            int LA8_0 = input.LA(1);

            if ( (LA8_0==30) ) {
                alt8=1;
            }
            else if ( (LA8_0==32) ) {
                alt8=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 8, 0, input);

                throw nvae;
            }
            switch (alt8) {
                case 1 :
                    // ttcn3tree.g:459:4: recordDef
                    {
                    pushFollow(FOLLOW_recordDef_in_structuredTypeDef610);
                    recordDef14=recordDef();

                    state._fsp--;

                    retval.t = (recordDef14!=null?recordDef14.t:null);


                    // TEMPLATE REWRITE
                    // 459:36: -> {$recordDef.st}
                    {
                        retval.st = (recordDef14!=null?recordDef14.st:null);
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:460:4: componentDef
                    {
                    pushFollow(FOLLOW_componentDef_in_structuredTypeDef622);
                    componentDef15=componentDef();

                    state._fsp--;

                    retval.t = (componentDef15!=null?componentDef15.t:null);


                    // TEMPLATE REWRITE
                    // 460:42: -> {$componentDef.st}
                    {
                        retval.st = (componentDef15!=null?componentDef15.st:null);
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "structuredTypeDef"

    public static class recordDef_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "recordDef"
    // ttcn3tree.g:462:1: recordDef returns [TType t] : ^( 'record' structDefBody ) -> typeRecordDef(newname=$structDefBody.idtexttypes=$structDefBody.typesfields=$structDefBody.fieldstoken=$structDefBody.token1desc=$text);
    public final ttcn3tree.recordDef_return recordDef() throws RecognitionException {
        ttcn3tree.recordDef_return retval = new ttcn3tree.recordDef_return();
        retval.start = input.LT(1);

        ttcn3tree.structDefBody_return structDefBody16 = null;


        try {
            // ttcn3tree.g:463:2: ( ^( 'record' structDefBody ) -> typeRecordDef(newname=$structDefBody.idtexttypes=$structDefBody.typesfields=$structDefBody.fieldstoken=$structDefBody.token1desc=$text))
            // ttcn3tree.g:463:4: ^( 'record' structDefBody )
            {
            match(input,30,FOLLOW_30_in_recordDef643); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_structDefBody_in_recordDef645);
            structDefBody16=structDefBody();

            state._fsp--;


            match(input, Token.UP, null); 
             allStructedTypeList.add((structDefBody16!=null?structDefBody16.idtext:null)); retval.t = (structDefBody16!=null?structDefBody16.t:null); 


            // TEMPLATE REWRITE
            // 464:3: -> typeRecordDef(newname=$structDefBody.idtexttypes=$structDefBody.typesfields=$structDefBody.fieldstoken=$structDefBody.token1desc=$text)
            {
                retval.st = templateLib.getInstanceOf("typeRecordDef",
              new STAttrMap().put("newname", (structDefBody16!=null?structDefBody16.idtext:null)).put("types", (structDefBody16!=null?structDefBody16.types:null)).put("fields", (structDefBody16!=null?structDefBody16.fields:null)).put("token", (structDefBody16!=null?structDefBody16.token1:null)).put("desc", input.getTokenStream().toString(
              input.getTreeAdaptor().getTokenStartIndex(retval.start),
              input.getTreeAdaptor().getTokenStopIndex(retval.start))));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "recordDef"

    public static class structDefBody_return extends TreeRuleReturnScope {
        public List types;
        public List fields;
        public String idtext;
        public Token token1;
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "structDefBody"
    // ttcn3tree.g:466:1: structDefBody returns [List types, List fields, String idtext, Token token1, TType t] : ^( id ( structFieldDef[$types, $fields] )+ ) ;
    public final ttcn3tree.structDefBody_return structDefBody() throws RecognitionException {
        ttcn3tree.structDefBody_return retval = new ttcn3tree.structDefBody_return();
        retval.start = input.LT(1);

        ttcn3tree.id_return id17 = null;



        	retval.types =new ArrayList();
        	retval.fields =new ArrayList(); 

        try {
            // ttcn3tree.g:471:2: ( ^( id ( structFieldDef[$types, $fields] )+ ) )
            // ttcn3tree.g:471:4: ^( id ( structFieldDef[$types, $fields] )+ )
            {
            pushFollow(FOLLOW_id_in_structDefBody698);
            id17=id();

            state._fsp--;


            match(input, Token.DOWN, null); 
            // ttcn3tree.g:471:9: ( structFieldDef[$types, $fields] )+
            int cnt9=0;
            loop9:
            do {
                int alt9=2;
                int LA9_0 = input.LA(1);

                if ( (LA9_0==ID) ) {
                    alt9=1;
                }


                switch (alt9) {
            	case 1 :
            	    // ttcn3tree.g:471:9: structFieldDef[$types, $fields]
            	    {
            	    pushFollow(FOLLOW_structFieldDef_in_structDefBody700);
            	    structFieldDef(retval.types, retval.fields);

            	    state._fsp--;


            	    }
            	    break;

            	default :
            	    if ( cnt9 >= 1 ) break loop9;
                        EarlyExitException eee =
                            new EarlyExitException(9, input);
                        throw eee;
                }
                cnt9++;
            } while (true);


            match(input, Token.UP, null); 

            		retval.idtext =(id17!=null?id17.text:null); retval.token1 =(id17!=null?id17.token:null);
            		retval.t = getRecord(moduleName, (id17!=null?id17.text:null), (id17!=null?id17.token:null));
            		

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "structDefBody"

    public static class structFieldDef_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "structFieldDef"
    // ttcn3tree.g:477:1: structFieldDef[List types, List fields] : ^( id typeName ) ;
    public final ttcn3tree.structFieldDef_return structFieldDef(List types, List fields) throws RecognitionException {
        ttcn3tree.structFieldDef_return retval = new ttcn3tree.structFieldDef_return();
        retval.start = input.LT(1);

        ttcn3tree.typeName_return typeName18 = null;

        ttcn3tree.id_return id19 = null;


        try {
            // ttcn3tree.g:478:2: ( ^( id typeName ) )
            // ttcn3tree.g:478:5: ^( id typeName )
            {
            pushFollow(FOLLOW_id_in_structFieldDef722);
            id19=id();

            state._fsp--;


            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_typeName_in_structFieldDef724);
            typeName18=typeName();

            state._fsp--;


            match(input, Token.UP, null); 
            types.add((typeName18!=null?typeName18.st:null)); fields.add((id19!=null?id19.text:null)); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "structFieldDef"

    public static class subTypeDef_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "subTypeDef"
    // ttcn3tree.g:481:1: subTypeDef returns [TType t] : ^( id typeName ) -> subTypeDef(isStruct=$typeName.t.getSubAttrib()==TSubAttribTYPE.RECORDoldname=$typeName.stnewname=$id.texttoken=$id.tokendesc=$text);
    public final ttcn3tree.subTypeDef_return subTypeDef() throws RecognitionException {
        ttcn3tree.subTypeDef_return retval = new ttcn3tree.subTypeDef_return();
        retval.start = input.LT(1);

        ttcn3tree.typeName_return typeName20 = null;

        ttcn3tree.id_return id21 = null;


        try {
            // ttcn3tree.g:482:2: ( ^( id typeName ) -> subTypeDef(isStruct=$typeName.t.getSubAttrib()==TSubAttribTYPE.RECORDoldname=$typeName.stnewname=$id.texttoken=$id.tokendesc=$text))
            // ttcn3tree.g:482:4: ^( id typeName )
            {
            pushFollow(FOLLOW_id_in_subTypeDef742);
            id21=id();

            state._fsp--;


            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_typeName_in_subTypeDef744);
            typeName20=typeName();

            state._fsp--;


            match(input, Token.UP, null); 

            			if((typeName20!=null?typeName20.t:null).getSubAttrib()==TSubAttribTYPE.RECORD)
            				allStructedTypeList.add((id21!=null?id21.text:null));
            			retval.t = getSubTypeDef(moduleName, (id21!=null?id21.text:null), (id21!=null?id21.token:null));
            		


            // TEMPLATE REWRITE
            // 488:6: -> subTypeDef(isStruct=$typeName.t.getSubAttrib()==TSubAttribTYPE.RECORDoldname=$typeName.stnewname=$id.texttoken=$id.tokendesc=$text)
            {
                retval.st = templateLib.getInstanceOf("subTypeDef",
              new STAttrMap().put("isStruct", (typeName20!=null?typeName20.t:null).getSubAttrib()==TSubAttribTYPE.RECORD).put("oldname", (typeName20!=null?typeName20.st:null)).put("newname", (id21!=null?id21.text:null)).put("token", (id21!=null?id21.token:null)).put("desc", input.getTokenStream().toString(
              input.getTreeAdaptor().getTokenStartIndex(retval.start),
              input.getTreeAdaptor().getTokenStopIndex(retval.start))));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "subTypeDef"

    public static class componentDef_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "componentDef"
    // ttcn3tree.g:491:1: componentDef returns [TType t] : ^( 'component' id ( componentDefList )? ) -> componentDefine(name=$id.textcomponentDefList=$componentDefList.elementListstoken=$id.tokendesc=\"component define:\"+$id.text);
    public final ttcn3tree.componentDef_return componentDef() throws RecognitionException {
        ttcn3tree.componentDef_return retval = new ttcn3tree.componentDef_return();
        retval.start = input.LT(1);

        ttcn3tree.id_return id22 = null;

        ttcn3tree.componentDefList_return componentDefList23 = null;


        try {
            // ttcn3tree.g:492:2: ( ^( 'component' id ( componentDefList )? ) -> componentDefine(name=$id.textcomponentDefList=$componentDefList.elementListstoken=$id.tokendesc=\"component define:\"+$id.text))
            // ttcn3tree.g:492:4: ^( 'component' id ( componentDefList )? )
            {
            match(input,32,FOLLOW_32_in_componentDef799); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_id_in_componentDef801);
            id22=id();

            state._fsp--;

            // ttcn3tree.g:492:21: ( componentDefList )?
            int alt10=2;
            int LA10_0 = input.LA(1);

            if ( (LA10_0==36||LA10_0==46) ) {
                alt10=1;
            }
            switch (alt10) {
                case 1 :
                    // ttcn3tree.g:492:21: componentDefList
                    {
                    pushFollow(FOLLOW_componentDefList_in_componentDef803);
                    componentDefList23=componentDefList();

                    state._fsp--;


                    }
                    break;

            }


            match(input, Token.UP, null); 

            		retval.t = getComponent(moduleName, (id22!=null?id22.text:null), (id22!=null?id22.token:null));
            		


            // TEMPLATE REWRITE
            // 496:3: -> componentDefine(name=$id.textcomponentDefList=$componentDefList.elementListstoken=$id.tokendesc=\"component define:\"+$id.text)
            {
                retval.st = templateLib.getInstanceOf("componentDefine",
              new STAttrMap().put("name", (id22!=null?id22.text:null)).put("componentDefList", (componentDefList23!=null?componentDefList23.elementLists:null)).put("token", (id22!=null?id22.token:null)).put("desc", "component define:"+(id22!=null?id22.text:null)));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "componentDef"

    public static class componentDefList_return extends TreeRuleReturnScope {
        public List elementLists;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "componentDefList"
    // ttcn3tree.g:498:1: componentDefList returns [List elementLists] : (locals+= componentElementDef )+ ;
    public final ttcn3tree.componentDefList_return componentDefList() throws RecognitionException {
        ttcn3tree.componentDefList_return retval = new ttcn3tree.componentDefList_return();
        retval.start = input.LT(1);

        List list_locals=null;
        ttcn3tree.componentElementDef_return locals = null;
         locals = null;
        try {
            // ttcn3tree.g:499:2: ( (locals+= componentElementDef )+ )
            // ttcn3tree.g:499:4: (locals+= componentElementDef )+
            {
            // ttcn3tree.g:499:4: (locals+= componentElementDef )+
            int cnt11=0;
            loop11:
            do {
                int alt11=2;
                int LA11_0 = input.LA(1);

                if ( (LA11_0==36||LA11_0==46) ) {
                    alt11=1;
                }


                switch (alt11) {
            	case 1 :
            	    // ttcn3tree.g:499:5: locals+= componentElementDef
            	    {
            	    pushFollow(FOLLOW_componentElementDef_in_componentDefList852);
            	    locals=componentElementDef();

            	    state._fsp--;

            	    if (list_locals==null) list_locals=new ArrayList();
            	    list_locals.add(locals.getTemplate());


            	    }
            	    break;

            	default :
            	    if ( cnt11 >= 1 ) break loop11;
                        EarlyExitException eee =
                            new EarlyExitException(11, input);
                        throw eee;
                }
                cnt11++;
            } while (true);

            retval.elementLists = list_locals;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "componentDefList"

    public static class componentElementDef_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "componentElementDef"
    // ttcn3tree.g:501:1: componentElementDef : ( varInstance -> {$varInstance.st} | constDef -> {$constDef.st});
    public final ttcn3tree.componentElementDef_return componentElementDef() throws RecognitionException {
        ttcn3tree.componentElementDef_return retval = new ttcn3tree.componentElementDef_return();
        retval.start = input.LT(1);

        ttcn3tree.varInstance_return varInstance24 = null;

        ttcn3tree.constDef_return constDef25 = null;


        try {
            // ttcn3tree.g:502:2: ( varInstance -> {$varInstance.st} | constDef -> {$constDef.st})
            int alt12=2;
            int LA12_0 = input.LA(1);

            if ( (LA12_0==46) ) {
                alt12=1;
            }
            else if ( (LA12_0==36) ) {
                alt12=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 12, 0, input);

                throw nvae;
            }
            switch (alt12) {
                case 1 :
                    // ttcn3tree.g:502:4: varInstance
                    {
                    pushFollow(FOLLOW_varInstance_in_componentElementDef866);
                    varInstance24=varInstance();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 502:16: -> {$varInstance.st}
                    {
                        retval.st = (varInstance24!=null?varInstance24.st:null);
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:503:4: constDef
                    {
                    pushFollow(FOLLOW_constDef_in_componentElementDef875);
                    constDef25=constDef();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 503:13: -> {$constDef.st}
                    {
                        retval.st = (constDef25!=null?constDef25.st:null);
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "componentElementDef"

    public static class typeName_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "typeName"
    // ttcn3tree.g:508:1: typeName returns [TType t] : (pt= 'integer' -> integerType(name=$pt.text) | pt= 'charstring' -> charstringType(name=$pt.text) | pt= 'boolean' -> booleanType(name=$pt.text) | pt2= id -> varRef(id=$pt2.text));
    public final ttcn3tree.typeName_return typeName() throws RecognitionException {
        ttcn3tree.typeName_return retval = new ttcn3tree.typeName_return();
        retval.start = input.LT(1);

        CommonTree pt=null;
        ttcn3tree.id_return pt2 = null;


        try {
            // ttcn3tree.g:509:3: (pt= 'integer' -> integerType(name=$pt.text) | pt= 'charstring' -> charstringType(name=$pt.text) | pt= 'boolean' -> booleanType(name=$pt.text) | pt2= id -> varRef(id=$pt2.text))
            int alt13=4;
            switch ( input.LA(1) ) {
            case 33:
                {
                alt13=1;
                }
                break;
            case 34:
                {
                alt13=2;
                }
                break;
            case 35:
                {
                alt13=3;
                }
                break;
            case ID:
                {
                alt13=4;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 13, 0, input);

                throw nvae;
            }

            switch (alt13) {
                case 1 :
                    // ttcn3tree.g:509:5: pt= 'integer'
                    {
                    pt=(CommonTree)match(input,33,FOLLOW_33_in_typeName899); 
                    retval.t = getPredefinedType((pt!=null?pt.getText():null));


                    // TEMPLATE REWRITE
                    // 510:6: -> integerType(name=$pt.text)
                    {
                        retval.st = templateLib.getInstanceOf("integerType",
                      new STAttrMap().put("name", (pt!=null?pt.getText():null)));
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:511:5: pt= 'charstring'
                    {
                    pt=(CommonTree)match(input,34,FOLLOW_34_in_typeName926); 
                    retval.t = getPredefinedType((pt!=null?pt.getText():null));


                    // TEMPLATE REWRITE
                    // 512:6: -> charstringType(name=$pt.text)
                    {
                        retval.st = templateLib.getInstanceOf("charstringType",
                      new STAttrMap().put("name", (pt!=null?pt.getText():null)));
                    }


                    }
                    break;
                case 3 :
                    // ttcn3tree.g:513:5: pt= 'boolean'
                    {
                    pt=(CommonTree)match(input,35,FOLLOW_35_in_typeName950); 
                    retval.t = getPredefinedType((pt!=null?pt.getText():null));


                    // TEMPLATE REWRITE
                    // 514:6: -> booleanType(name=$pt.text)
                    {
                        retval.st = templateLib.getInstanceOf("booleanType",
                      new STAttrMap().put("name", (pt!=null?pt.getText():null)));
                    }


                    }
                    break;
                case 4 :
                    // ttcn3tree.g:515:5: pt2= id
                    {
                    pushFollow(FOLLOW_id_in_typeName977);
                    pt2=id();

                    state._fsp--;

                    retval.t = getType(moduleName, (pt2!=null?pt2.token:null), TAttrib.TYPE, null);


                    // TEMPLATE REWRITE
                    // 516:6: -> varRef(id=$pt2.text)
                    {
                        retval.st = templateLib.getInstanceOf("varRef",
                      new STAttrMap().put("id", (pt2!=null?pt2.text:null)));
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "typeName"

    public static class constDef_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "constDef"
    // ttcn3tree.g:519:1: constDef : ^(c= 'const' typeName (init+= constInitial[$typeName.st] )+ ) -> constDefine(isInLocalSpace=$gBlockScope.size()!=0typename=$typeName.stconstRefs=$inittoken=$c.getToken()desc=$text);
    public final ttcn3tree.constDef_return constDef() throws RecognitionException {
        ttcn3tree.constDef_return retval = new ttcn3tree.constDef_return();
        retval.start = input.LT(1);

        CommonTree c=null;
        List list_init=null;
        ttcn3tree.typeName_return typeName26 = null;

        ttcn3tree.constInitial_return init = null;
         init = null;
        try {
            // ttcn3tree.g:520:3: ( ^(c= 'const' typeName (init+= constInitial[$typeName.st] )+ ) -> constDefine(isInLocalSpace=$gBlockScope.size()!=0typename=$typeName.stconstRefs=$inittoken=$c.getToken()desc=$text))
            // ttcn3tree.g:520:5: ^(c= 'const' typeName (init+= constInitial[$typeName.st] )+ )
            {
            c=(CommonTree)match(input,36,FOLLOW_36_in_constDef1020); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_typeName_in_constDef1022);
            typeName26=typeName();

            state._fsp--;

            // ttcn3tree.g:520:27: (init+= constInitial[$typeName.st] )+
            int cnt14=0;
            loop14:
            do {
                int alt14=2;
                int LA14_0 = input.LA(1);

                if ( (LA14_0==37) ) {
                    alt14=1;
                }


                switch (alt14) {
            	case 1 :
            	    // ttcn3tree.g:520:29: init+= constInitial[$typeName.st]
            	    {
            	    pushFollow(FOLLOW_constInitial_in_constDef1028);
            	    init=constInitial((typeName26!=null?typeName26.st:null));

            	    state._fsp--;

            	    if (list_init==null) list_init=new ArrayList();
            	    list_init.add(init.getTemplate());


            	    }
            	    break;

            	default :
            	    if ( cnt14 >= 1 ) break loop14;
                        EarlyExitException eee =
                            new EarlyExitException(14, input);
                        throw eee;
                }
                cnt14++;
            } while (true);


            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 521:6: -> constDefine(isInLocalSpace=$gBlockScope.size()!=0typename=$typeName.stconstRefs=$inittoken=$c.getToken()desc=$text)
            {
                retval.st = templateLib.getInstanceOf("constDefine",
              new STAttrMap().put("isInLocalSpace", gBlockScope_stack.size()!=0).put("typename", (typeName26!=null?typeName26.st:null)).put("constRefs", list_init).put("token", c.getToken()).put("desc", input.getTokenStream().toString(
              input.getTreeAdaptor().getTokenStartIndex(retval.start),
              input.getTreeAdaptor().getTokenStopIndex(retval.start))));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "constDef"

    public static class constInitial_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "constInitial"
    // ttcn3tree.g:524:1: constInitial[StringTemplate datatype] : ^(st= ':=' id constExpr ) -> varOrConstInitial(typeName=$datatypeleft=$id.textright=$constExpr.stisComponent=false);
    public final ttcn3tree.constInitial_return constInitial(StringTemplate datatype) throws RecognitionException {
        ttcn3tree.constInitial_return retval = new ttcn3tree.constInitial_return();
        retval.start = input.LT(1);

        CommonTree st=null;
        ttcn3tree.id_return id27 = null;

        ttcn3tree.constExpr_return constExpr28 = null;


        try {
            // ttcn3tree.g:525:3: ( ^(st= ':=' id constExpr ) -> varOrConstInitial(typeName=$datatypeleft=$id.textright=$constExpr.stisComponent=false))
            // ttcn3tree.g:525:5: ^(st= ':=' id constExpr )
            {
            st=(CommonTree)match(input,37,FOLLOW_37_in_constInitial1087); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_id_in_constInitial1089);
            id27=id();

            state._fsp--;

            pushFollow(FOLLOW_constExpr_in_constInitial1091);
            constExpr28=constExpr();

            state._fsp--;


            match(input, Token.UP, null); 

            	        TType idType = getType(moduleName, (id27!=null?id27.token:null), TAttrib.VALUE, null); 
            	        doAssignment(st.getToken(), idType, (constExpr28!=null?constExpr28.t:null), true);
            	    


            // TEMPLATE REWRITE
            // 530:6: -> varOrConstInitial(typeName=$datatypeleft=$id.textright=$constExpr.stisComponent=false)
            {
                retval.st = templateLib.getInstanceOf("varOrConstInitial",
              new STAttrMap().put("typeName", datatype).put("left", (id27!=null?id27.text:null)).put("right", (constExpr28!=null?constExpr28.st:null)).put("isComponent", false));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "constInitial"

    public static class functionDef_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "functionDef"
    // ttcn3tree.g:533:1: functionDef : ^( 'function' id ( functionFormalParList[formalArgs] )? ( runsOnSpec )? ( returnType )? statementBlock[typeFunc==null?null:typeFunc.getSubTable()] ) -> functionDefine(name=$id.textargs=formalArgsrunsOn=$runsOnSpec.streturnType=$returnType.ststatements=$statementBlock.sttoken=$id.tokendesc=\"Function define in module \\\"\"+moduleName+\"\\\"\");
    public final ttcn3tree.functionDef_return functionDef() throws RecognitionException {
        ttcn3tree.functionDef_return retval = new ttcn3tree.functionDef_return();
        retval.start = input.LT(1);

        ttcn3tree.id_return id29 = null;

        ttcn3tree.returnType_return returnType30 = null;

        ttcn3tree.runsOnSpec_return runsOnSpec31 = null;

        ttcn3tree.statementBlock_return statementBlock32 = null;



            isInFunctionDef=true;
            currentFuncName=null;
            currentFuncReturnType=null;
            currentFuncReturnTypeST=null;
            runsOnComp = null;
            runsOnSystem = null;
            Map formalArgs = new LinkedHashMap();

        try {
            // ttcn3tree.g:551:3: ( ^( 'function' id ( functionFormalParList[formalArgs] )? ( runsOnSpec )? ( returnType )? statementBlock[typeFunc==null?null:typeFunc.getSubTable()] ) -> functionDefine(name=$id.textargs=formalArgsrunsOn=$runsOnSpec.streturnType=$returnType.ststatements=$statementBlock.sttoken=$id.tokendesc=\"Function define in module \\\"\"+moduleName+\"\\\"\"))
            // ttcn3tree.g:551:5: ^( 'function' id ( functionFormalParList[formalArgs] )? ( runsOnSpec )? ( returnType )? statementBlock[typeFunc==null?null:typeFunc.getSubTable()] )
            {
            match(input,38,FOLLOW_38_in_functionDef1151); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_id_in_functionDef1153);
            id29=id();

            state._fsp--;

            // ttcn3tree.g:551:22: ( functionFormalParList[formalArgs] )?
            int alt15=2;
            int LA15_0 = input.LA(1);

            if ( (LA15_0==FORMAL_ARGS) ) {
                alt15=1;
            }
            switch (alt15) {
                case 1 :
                    // ttcn3tree.g:551:22: functionFormalParList[formalArgs]
                    {
                    pushFollow(FOLLOW_functionFormalParList_in_functionDef1155);
                    functionFormalParList(formalArgs);

                    state._fsp--;


                    }
                    break;

            }

            // ttcn3tree.g:551:57: ( runsOnSpec )?
            int alt16=2;
            int LA16_0 = input.LA(1);

            if ( (LA16_0==RUNS_ON) ) {
                alt16=1;
            }
            switch (alt16) {
                case 1 :
                    // ttcn3tree.g:551:57: runsOnSpec
                    {
                    pushFollow(FOLLOW_runsOnSpec_in_functionDef1159);
                    runsOnSpec31=runsOnSpec();

                    state._fsp--;


                    }
                    break;

            }

            // ttcn3tree.g:551:69: ( returnType )?
            int alt17=2;
            int LA17_0 = input.LA(1);

            if ( (LA17_0==41) ) {
                alt17=1;
            }
            switch (alt17) {
                case 1 :
                    // ttcn3tree.g:551:69: returnType
                    {
                    pushFollow(FOLLOW_returnType_in_functionDef1162);
                    returnType30=returnType();

                    state._fsp--;


                    }
                    break;

            }


            	        currentFuncName = (id29!=null?id29.text:null);
            	        currentFuncReturnTypeST = (returnType30!=null?returnType30.st:null);
            	        FunctionType typeFunc = (FunctionType)getType(moduleName, (id29!=null?id29.token:null), TAttrib.FUNCTION, null);
            	        typeFunc.setFormalArgs(formalArgs);
            	        
            	        if((runsOnSpec31!=null?runsOnSpec31.st:null)!=null)
            	        	((ttcn3Module_scope)ttcn3Module_stack.peek()).callableList.add(CallableBean.valueOf(moduleName, (id29!=null?id29.text:null), runsOnComp, null));
            	        
            	      
            pushFollow(FOLLOW_statementBlock_in_functionDef1182);
            statementBlock32=statementBlock(typeFunc==null?null:typeFunc.getSubTable());

            state._fsp--;


            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 564:5: -> functionDefine(name=$id.textargs=formalArgsrunsOn=$runsOnSpec.streturnType=$returnType.ststatements=$statementBlock.sttoken=$id.tokendesc=\"Function define in module \\\"\"+moduleName+\"\\\"\")
            {
                retval.st = templateLib.getInstanceOf("functionDefine",
              new STAttrMap().put("name", (id29!=null?id29.text:null)).put("args", formalArgs).put("runsOn", (runsOnSpec31!=null?runsOnSpec31.st:null)).put("returnType", (returnType30!=null?returnType30.st:null)).put("statements", (statementBlock32!=null?statementBlock32.st:null)).put("token", (id29!=null?id29.token:null)).put("desc", "Function define in module \""+moduleName+"\""));
            }


            }


                isInFunctionDef=false;
                currentFuncName=null;
                currentFuncReturnType=null;
                currentFuncReturnTypeST=null;
                runsOnComp = null;
                runsOnSystem = null;

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "functionDef"

    public static class returnType_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "returnType"
    // ttcn3tree.g:568:1: returnType : ^( 'return' typeName ) -> {$typeName.st};
    public final ttcn3tree.returnType_return returnType() throws RecognitionException {
        ttcn3tree.returnType_return retval = new ttcn3tree.returnType_return();
        retval.start = input.LT(1);

        ttcn3tree.typeName_return typeName33 = null;


        try {
            // ttcn3tree.g:569:3: ( ^( 'return' typeName ) -> {$typeName.st})
            // ttcn3tree.g:569:5: ^( 'return' typeName )
            {
            match(input,41,FOLLOW_41_in_returnType1268); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_typeName_in_returnType1270);
            typeName33=typeName();

            state._fsp--;


            match(input, Token.UP, null); 
            currentFuncReturnType = (typeName33!=null?typeName33.t:null);


            // TEMPLATE REWRITE
            // 570:5: -> {$typeName.st}
            {
                retval.st = (typeName33!=null?typeName33.st:null);
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "returnType"

    public static class runsOnSpec_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "runsOnSpec"
    // ttcn3tree.g:573:1: runsOnSpec : ^( RUNS_ON componentType ) -> unmodified(text=$componentType.text);
    public final ttcn3tree.runsOnSpec_return runsOnSpec() throws RecognitionException {
        ttcn3tree.runsOnSpec_return retval = new ttcn3tree.runsOnSpec_return();
        retval.start = input.LT(1);

        ttcn3tree.componentType_return componentType34 = null;


        try {
            // ttcn3tree.g:574:2: ( ^( RUNS_ON componentType ) -> unmodified(text=$componentType.text))
            // ttcn3tree.g:574:4: ^( RUNS_ON componentType )
            {
            match(input,RUNS_ON,FOLLOW_RUNS_ON_in_runsOnSpec1294); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_componentType_in_runsOnSpec1296);
            componentType34=componentType();

            state._fsp--;


            match(input, Token.UP, null); 
            runsOnComp=(componentType34!=null?componentType34.text:null);


            // TEMPLATE REWRITE
            // 574:68: -> unmodified(text=$componentType.text)
            {
                retval.st = templateLib.getInstanceOf("unmodified",
              new STAttrMap().put("text", (componentType34!=null?componentType34.text:null)));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "runsOnSpec"

    public static class functionFormalParList_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "functionFormalParList"
    // ttcn3tree.g:577:1: functionFormalParList[Map formalArgs] : ^( FORMAL_ARGS ( functionFormalPar )+ ) ;
    public final ttcn3tree.functionFormalParList_return functionFormalParList(Map formalArgs) throws RecognitionException {
        ttcn3tree.functionFormalParList_return retval = new ttcn3tree.functionFormalParList_return();
        retval.start = input.LT(1);

        ttcn3tree.functionFormalPar_return functionFormalPar35 = null;


        try {
            // ttcn3tree.g:578:2: ( ^( FORMAL_ARGS ( functionFormalPar )+ ) )
            // ttcn3tree.g:578:4: ^( FORMAL_ARGS ( functionFormalPar )+ )
            {
            match(input,FORMAL_ARGS,FOLLOW_FORMAL_ARGS_in_functionFormalParList1327); 

            match(input, Token.DOWN, null); 
            // ttcn3tree.g:578:18: ( functionFormalPar )+
            int cnt18=0;
            loop18:
            do {
                int alt18=2;
                int LA18_0 = input.LA(1);

                if ( (LA18_0==FORMAL_VAR) ) {
                    alt18=1;
                }


                switch (alt18) {
            	case 1 :
            	    // ttcn3tree.g:578:19: functionFormalPar
            	    {
            	    pushFollow(FOLLOW_functionFormalPar_in_functionFormalParList1330);
            	    functionFormalPar35=functionFormalPar();

            	    state._fsp--;

            	    formalArgs.put((functionFormalPar35!=null?functionFormalPar35.token:null).getText(), (functionFormalPar35!=null?functionFormalPar35.typeST:null));

            	    }
            	    break;

            	default :
            	    if ( cnt18 >= 1 ) break loop18;
                        EarlyExitException eee =
                            new EarlyExitException(18, input);
                        throw eee;
                }
                cnt18++;
            } while (true);


            match(input, Token.UP, null); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "functionFormalParList"

    public static class functionFormalPar_return extends TreeRuleReturnScope {
        public StringTemplate typeST;
        public Token token;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "functionFormalPar"
    // ttcn3tree.g:582:1: functionFormalPar returns [StringTemplate typeST, Token token] : formalValuePar ;
    public final ttcn3tree.functionFormalPar_return functionFormalPar() throws RecognitionException {
        ttcn3tree.functionFormalPar_return retval = new ttcn3tree.functionFormalPar_return();
        retval.start = input.LT(1);

        ttcn3tree.formalValuePar_return formalValuePar36 = null;


        try {
            // ttcn3tree.g:583:2: ( formalValuePar )
            // ttcn3tree.g:583:4: formalValuePar
            {
            pushFollow(FOLLOW_formalValuePar_in_functionFormalPar1364);
            formalValuePar36=formalValuePar();

            state._fsp--;


            		retval.typeST = (formalValuePar36!=null?formalValuePar36.typeST:null);
            		retval.token = (formalValuePar36!=null?formalValuePar36.token:null);
            		

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "functionFormalPar"

    public static class formalValuePar_return extends TreeRuleReturnScope {
        public StringTemplate typeST;
        public Token token;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "formalValuePar"
    // ttcn3tree.g:589:1: formalValuePar returns [StringTemplate typeST, Token token] : ^( FORMAL_VAR typeName id ) ;
    public final ttcn3tree.formalValuePar_return formalValuePar() throws RecognitionException {
        ttcn3tree.formalValuePar_return retval = new ttcn3tree.formalValuePar_return();
        retval.start = input.LT(1);

        ttcn3tree.typeName_return typeName37 = null;

        ttcn3tree.id_return id38 = null;


        try {
            // ttcn3tree.g:590:2: ( ^( FORMAL_VAR typeName id ) )
            // ttcn3tree.g:590:5: ^( FORMAL_VAR typeName id )
            {
            match(input,FORMAL_VAR,FOLLOW_FORMAL_VAR_in_formalValuePar1384); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_typeName_in_formalValuePar1386);
            typeName37=typeName();

            state._fsp--;

            pushFollow(FOLLOW_id_in_formalValuePar1388);
            id38=id();

            state._fsp--;


            match(input, Token.UP, null); 

            		retval.typeST = (typeName37!=null?typeName37.st:null);
            		retval.token = (id38!=null?id38.token:null);
            		

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "formalValuePar"

    public static class statementBlock_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "statementBlock"
    // ttcn3tree.g:599:1: statementBlock[HashMap<String, TType> varDefs] : ^( BLOCK ( functionStatementOrDefList )? ) -> statementBlocks(localRefs=$functionStatementOrDefList.localRefs);
    public final ttcn3tree.statementBlock_return statementBlock(HashMap<String, TType> varDefs) throws RecognitionException {
        gBlockScope_stack.push(new gBlockScope_scope());

        ttcn3tree.statementBlock_return retval = new ttcn3tree.statementBlock_return();
        retval.start = input.LT(1);

        ttcn3tree.functionStatementOrDefList_return functionStatementOrDefList39 = null;



            isInStatementBlock=true;
            ((gBlockScope_scope)gBlockScope_stack.peek()).symtbl = new Symtbl();
            //((gBlockScope_scope)gBlockScope_stack.peek()).st_localDef = new LinkedList();
            //((gBlockScope_scope)gBlockScope_stack.peek()).st_localStatement = new LinkedList();
            
            /* Addding formal arguments to local definition space. */
            if(null != varDefs) {
                for(Iterator<String> iter = varDefs.keySet().iterator(); iter.hasNext();){
                    String key = iter.next();
                    ((gBlockScope_scope)gBlockScope_stack.peek()).symtbl.addTypeFast(key, varDefs.get(key));
                }
            }

        try {
            // ttcn3tree.g:619:3: ( ^( BLOCK ( functionStatementOrDefList )? ) -> statementBlocks(localRefs=$functionStatementOrDefList.localRefs))
            // ttcn3tree.g:619:5: ^( BLOCK ( functionStatementOrDefList )? )
            {
            match(input,BLOCK,FOLLOW_BLOCK_in_statementBlock1425); 

            if ( input.LA(1)==Token.DOWN ) {
                match(input, Token.DOWN, null); 
                // ttcn3tree.g:619:14: ( functionStatementOrDefList )?
                int alt19=2;
                alt19 = dfa19.predict(input);
                switch (alt19) {
                    case 1 :
                        // ttcn3tree.g:619:16: functionStatementOrDefList
                        {
                        pushFollow(FOLLOW_functionStatementOrDefList_in_statementBlock1429);
                        functionStatementOrDefList39=functionStatementOrDefList();

                        state._fsp--;


                        }
                        break;

                }


                match(input, Token.UP, null); 
            }


            // TEMPLATE REWRITE
            // 621:6: -> statementBlocks(localRefs=$functionStatementOrDefList.localRefs)
            {
                retval.st = templateLib.getInstanceOf("statementBlocks",
              new STAttrMap().put("localRefs", (functionStatementOrDefList39!=null?functionStatementOrDefList39.localRefs:null)));
            }


            }


                //System.out.println("deep="+$statementBlock.size());
                isInStatementBlock=false;

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
            gBlockScope_stack.pop();

        }
        return retval;
    }
    // $ANTLR end "statementBlock"

    public static class functionStatementOrDefList_return extends TreeRuleReturnScope {
        public List localRefs;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "functionStatementOrDefList"
    // ttcn3tree.g:624:1: functionStatementOrDefList returns [List localRefs] : (locals+= functionStatementOrDef )+ ;
    public final ttcn3tree.functionStatementOrDefList_return functionStatementOrDefList() throws RecognitionException {
        ttcn3tree.functionStatementOrDefList_return retval = new ttcn3tree.functionStatementOrDefList_return();
        retval.start = input.LT(1);

        List list_locals=null;
        ttcn3tree.functionStatementOrDef_return locals = null;
         locals = null;
        try {
            // ttcn3tree.g:625:3: ( (locals+= functionStatementOrDef )+ )
            // ttcn3tree.g:625:5: (locals+= functionStatementOrDef )+
            {
            // ttcn3tree.g:625:5: (locals+= functionStatementOrDef )+
            int cnt20=0;
            loop20:
            do {
                int alt20=2;
                alt20 = dfa20.predict(input);
                switch (alt20) {
            	case 1 :
            	    // ttcn3tree.g:625:7: locals+= functionStatementOrDef
            	    {
            	    pushFollow(FOLLOW_functionStatementOrDef_in_functionStatementOrDefList1476);
            	    locals=functionStatementOrDef();

            	    state._fsp--;

            	    if (list_locals==null) list_locals=new ArrayList();
            	    list_locals.add(locals.getTemplate());


            	    }
            	    break;

            	default :
            	    if ( cnt20 >= 1 ) break loop20;
                        EarlyExitException eee =
                            new EarlyExitException(20, input);
                        throw eee;
                }
                cnt20++;
            } while (true);

             retval.localRefs = list_locals; 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "functionStatementOrDefList"

    public static class functionStatementOrDef_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "functionStatementOrDef"
    // ttcn3tree.g:628:1: functionStatementOrDef : ( functionLocalDef -> {$functionLocalDef.st} | functionStatement -> {$functionStatement.st});
    public final ttcn3tree.functionStatementOrDef_return functionStatementOrDef() throws RecognitionException {
        ttcn3tree.functionStatementOrDef_return retval = new ttcn3tree.functionStatementOrDef_return();
        retval.start = input.LT(1);

        ttcn3tree.functionLocalDef_return functionLocalDef40 = null;

        ttcn3tree.functionStatement_return functionStatement41 = null;


        try {
            // ttcn3tree.g:629:3: ( functionLocalDef -> {$functionLocalDef.st} | functionStatement -> {$functionStatement.st})
            int alt21=2;
            alt21 = dfa21.predict(input);
            switch (alt21) {
                case 1 :
                    // ttcn3tree.g:629:5: functionLocalDef
                    {
                    pushFollow(FOLLOW_functionLocalDef_in_functionStatementOrDef1494);
                    functionLocalDef40=functionLocalDef();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 629:25: -> {$functionLocalDef.st}
                    {
                        retval.st = (functionLocalDef40!=null?functionLocalDef40.st:null);
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:630:5: functionStatement
                    {
                    pushFollow(FOLLOW_functionStatement_in_functionStatementOrDef1508);
                    functionStatement41=functionStatement();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 630:25: -> {$functionStatement.st}
                    {
                        retval.st = (functionStatement41!=null?functionStatement41.st:null);
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "functionStatementOrDef"

    public static class functionLocalDef_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "functionLocalDef"
    // ttcn3tree.g:633:1: functionLocalDef : ( constDef -> {$constDef.st} | varInstance -> {$varInstance.st});
    public final ttcn3tree.functionLocalDef_return functionLocalDef() throws RecognitionException {
        ttcn3tree.functionLocalDef_return retval = new ttcn3tree.functionLocalDef_return();
        retval.start = input.LT(1);

        ttcn3tree.constDef_return constDef42 = null;

        ttcn3tree.varInstance_return varInstance43 = null;


        try {
            // ttcn3tree.g:634:3: ( constDef -> {$constDef.st} | varInstance -> {$varInstance.st})
            int alt22=2;
            int LA22_0 = input.LA(1);

            if ( (LA22_0==36) ) {
                alt22=1;
            }
            else if ( (LA22_0==46) ) {
                alt22=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 22, 0, input);

                throw nvae;
            }
            switch (alt22) {
                case 1 :
                    // ttcn3tree.g:634:5: constDef
                    {
                    pushFollow(FOLLOW_constDef_in_functionLocalDef1528);
                    constDef42=constDef();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 634:18: -> {$constDef.st}
                    {
                        retval.st = (constDef42!=null?constDef42.st:null);
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:635:5: varInstance
                    {
                    pushFollow(FOLLOW_varInstance_in_functionLocalDef1542);
                    varInstance43=varInstance();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 635:23: -> {$varInstance.st}
                    {
                        retval.st = (varInstance43!=null?varInstance43.st:null);
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "functionLocalDef"

    public static class testcaseDef_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "testcaseDef"
    // ttcn3tree.g:638:1: testcaseDef : ^( 'testcase' id '(' ( testcaseFormalParList[formalArgs] )? ')' runsOnSpec ( systemSpec )? statementBlock[typeCase.getSubTable()] ) -> testcaseDefine(name=$id.textargs=formalArgsrunsOn=$runsOnSpec.stsystemOn=$systemSpec.ststatements=$statementBlock.sttoken=$id.tokendesc=\"testcase define:\"+$id.text);
    public final ttcn3tree.testcaseDef_return testcaseDef() throws RecognitionException {
        ttcn3tree.testcaseDef_return retval = new ttcn3tree.testcaseDef_return();
        retval.start = input.LT(1);

        ttcn3tree.id_return id44 = null;

        ttcn3tree.runsOnSpec_return runsOnSpec45 = null;

        ttcn3tree.systemSpec_return systemSpec46 = null;

        ttcn3tree.statementBlock_return statementBlock47 = null;



            runsOnComp = null;
            runsOnSystem = null;
            Map formalArgs = new LinkedHashMap();

        try {
            // ttcn3tree.g:651:2: ( ^( 'testcase' id '(' ( testcaseFormalParList[formalArgs] )? ')' runsOnSpec ( systemSpec )? statementBlock[typeCase.getSubTable()] ) -> testcaseDefine(name=$id.textargs=formalArgsrunsOn=$runsOnSpec.stsystemOn=$systemSpec.ststatements=$statementBlock.sttoken=$id.tokendesc=\"testcase define:\"+$id.text))
            // ttcn3tree.g:651:4: ^( 'testcase' id '(' ( testcaseFormalParList[formalArgs] )? ')' runsOnSpec ( systemSpec )? statementBlock[typeCase.getSubTable()] )
            {
            match(input,44,FOLLOW_44_in_testcaseDef1575); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_id_in_testcaseDef1577);
            id44=id();

            state._fsp--;

            match(input,39,FOLLOW_39_in_testcaseDef1580); 
            // ttcn3tree.g:651:25: ( testcaseFormalParList[formalArgs] )?
            int alt23=2;
            int LA23_0 = input.LA(1);

            if ( (LA23_0==FORMAL_ARGS) ) {
                alt23=1;
            }
            switch (alt23) {
                case 1 :
                    // ttcn3tree.g:651:25: testcaseFormalParList[formalArgs]
                    {
                    pushFollow(FOLLOW_testcaseFormalParList_in_testcaseDef1582);
                    testcaseFormalParList(formalArgs);

                    state._fsp--;


                    }
                    break;

            }

            match(input,40,FOLLOW_40_in_testcaseDef1586); 
            pushFollow(FOLLOW_runsOnSpec_in_testcaseDef1588);
            runsOnSpec45=runsOnSpec();

            state._fsp--;

            // ttcn3tree.g:651:75: ( systemSpec )?
            int alt24=2;
            int LA24_0 = input.LA(1);

            if ( (LA24_0==45) ) {
                alt24=1;
            }
            switch (alt24) {
                case 1 :
                    // ttcn3tree.g:651:75: systemSpec
                    {
                    pushFollow(FOLLOW_systemSpec_in_testcaseDef1590);
                    systemSpec46=systemSpec();

                    state._fsp--;


                    }
                    break;

            }


            			TestcaseType typeCase = (TestcaseType)getType(moduleName, (id44!=null?id44.token:null), TAttrib.TESTCASE, null);
            	        typeCase.setFormalArgs(formalArgs);
            	        
            	        ((ttcn3Module_scope)ttcn3Module_stack.peek()).callableList.add(CallableBean.valueOf(moduleName, (id44!=null?id44.text:null), runsOnComp, runsOnSystem));
            	        
            		
            pushFollow(FOLLOW_statementBlock_in_testcaseDef1600);
            statementBlock47=statementBlock(typeCase.getSubTable());

            state._fsp--;


            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 661:3: -> testcaseDefine(name=$id.textargs=formalArgsrunsOn=$runsOnSpec.stsystemOn=$systemSpec.ststatements=$statementBlock.sttoken=$id.tokendesc=\"testcase define:\"+$id.text)
            {
                retval.st = templateLib.getInstanceOf("testcaseDefine",
              new STAttrMap().put("name", (id44!=null?id44.text:null)).put("args", formalArgs).put("runsOn", (runsOnSpec45!=null?runsOnSpec45.st:null)).put("systemOn", (systemSpec46!=null?systemSpec46.st:null)).put("statements", (statementBlock47!=null?statementBlock47.st:null)).put("token", (id44!=null?id44.token:null)).put("desc", "testcase define:"+(id44!=null?id44.text:null)));
            }


            }


                runsOnComp = null;
                runsOnSystem = null;

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "testcaseDef"

    public static class systemSpec_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "systemSpec"
    // ttcn3tree.g:663:1: systemSpec : ^( 'system' id ) -> unmodified(text=$id.text);
    public final ttcn3tree.systemSpec_return systemSpec() throws RecognitionException {
        ttcn3tree.systemSpec_return retval = new ttcn3tree.systemSpec_return();
        retval.start = input.LT(1);

        ttcn3tree.id_return id48 = null;


        try {
            // ttcn3tree.g:664:2: ( ^( 'system' id ) -> unmodified(text=$id.text))
            // ttcn3tree.g:664:4: ^( 'system' id )
            {
            match(input,45,FOLLOW_45_in_systemSpec1658); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_id_in_systemSpec1660);
            id48=id();

            state._fsp--;


            match(input, Token.UP, null); 
            runsOnSystem=(id48!=null?id48.text:null);


            // TEMPLATE REWRITE
            // 664:44: -> unmodified(text=$id.text)
            {
                retval.st = templateLib.getInstanceOf("unmodified",
              new STAttrMap().put("text", (id48!=null?id48.text:null)));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "systemSpec"

    public static class testcaseFormalParList_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "testcaseFormalParList"
    // ttcn3tree.g:666:1: testcaseFormalParList[Map formalArgs] : ^( FORMAL_ARGS ( testcaseFormalPar )+ ) ;
    public final ttcn3tree.testcaseFormalParList_return testcaseFormalParList(Map formalArgs) throws RecognitionException {
        ttcn3tree.testcaseFormalParList_return retval = new ttcn3tree.testcaseFormalParList_return();
        retval.start = input.LT(1);

        ttcn3tree.testcaseFormalPar_return testcaseFormalPar49 = null;


        try {
            // ttcn3tree.g:667:2: ( ^( FORMAL_ARGS ( testcaseFormalPar )+ ) )
            // ttcn3tree.g:667:4: ^( FORMAL_ARGS ( testcaseFormalPar )+ )
            {
            match(input,FORMAL_ARGS,FOLLOW_FORMAL_ARGS_in_testcaseFormalParList1685); 

            match(input, Token.DOWN, null); 
            // ttcn3tree.g:667:18: ( testcaseFormalPar )+
            int cnt25=0;
            loop25:
            do {
                int alt25=2;
                int LA25_0 = input.LA(1);

                if ( (LA25_0==FORMAL_VAR) ) {
                    alt25=1;
                }


                switch (alt25) {
            	case 1 :
            	    // ttcn3tree.g:667:19: testcaseFormalPar
            	    {
            	    pushFollow(FOLLOW_testcaseFormalPar_in_testcaseFormalParList1688);
            	    testcaseFormalPar49=testcaseFormalPar();

            	    state._fsp--;

            	    formalArgs.put((testcaseFormalPar49!=null?testcaseFormalPar49.token:null).getText(),(testcaseFormalPar49!=null?testcaseFormalPar49.typeST:null));

            	    }
            	    break;

            	default :
            	    if ( cnt25 >= 1 ) break loop25;
                        EarlyExitException eee =
                            new EarlyExitException(25, input);
                        throw eee;
                }
                cnt25++;
            } while (true);


            match(input, Token.UP, null); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "testcaseFormalParList"

    public static class testcaseFormalPar_return extends TreeRuleReturnScope {
        public StringTemplate typeST;
        public Token token;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "testcaseFormalPar"
    // ttcn3tree.g:669:1: testcaseFormalPar returns [StringTemplate typeST, Token token] : formalValuePar ;
    public final ttcn3tree.testcaseFormalPar_return testcaseFormalPar() throws RecognitionException {
        ttcn3tree.testcaseFormalPar_return retval = new ttcn3tree.testcaseFormalPar_return();
        retval.start = input.LT(1);

        ttcn3tree.formalValuePar_return formalValuePar50 = null;


        try {
            // ttcn3tree.g:670:2: ( formalValuePar )
            // ttcn3tree.g:670:4: formalValuePar
            {
            pushFollow(FOLLOW_formalValuePar_in_testcaseFormalPar1710);
            formalValuePar50=formalValuePar();

            state._fsp--;


            			retval.typeST = (formalValuePar50!=null?formalValuePar50.typeST:null);
            			retval.token = (formalValuePar50!=null?formalValuePar50.token:null);
            		

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "testcaseFormalPar"

    public static class varInstance_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "varInstance"
    // ttcn3tree.g:679:1: varInstance : ^(v= 'var' typeName (vars+= var[$typeName.t, $typeName.st] )+ ) -> varDefine(typename=$typeName.stvarRefs=$varstoken=$v.getToken()desc=$text);
    public final ttcn3tree.varInstance_return varInstance() throws RecognitionException {
        ttcn3tree.varInstance_return retval = new ttcn3tree.varInstance_return();
        retval.start = input.LT(1);

        CommonTree v=null;
        List list_vars=null;
        ttcn3tree.typeName_return typeName51 = null;

        ttcn3tree.var_return vars = null;
         vars = null;
        try {
            // ttcn3tree.g:680:3: ( ^(v= 'var' typeName (vars+= var[$typeName.t, $typeName.st] )+ ) -> varDefine(typename=$typeName.stvarRefs=$varstoken=$v.getToken()desc=$text))
            // ttcn3tree.g:680:5: ^(v= 'var' typeName (vars+= var[$typeName.t, $typeName.st] )+ )
            {
            v=(CommonTree)match(input,46,FOLLOW_46_in_varInstance1734); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_typeName_in_varInstance1736);
            typeName51=typeName();

            state._fsp--;

            // ttcn3tree.g:680:25: (vars+= var[$typeName.t, $typeName.st] )+
            int cnt26=0;
            loop26:
            do {
                int alt26=2;
                int LA26_0 = input.LA(1);

                if ( (LA26_0==ID||LA26_0==37) ) {
                    alt26=1;
                }


                switch (alt26) {
            	case 1 :
            	    // ttcn3tree.g:680:27: vars+= var[$typeName.t, $typeName.st]
            	    {
            	    pushFollow(FOLLOW_var_in_varInstance1742);
            	    vars=var((typeName51!=null?typeName51.t:null), (typeName51!=null?typeName51.st:null));

            	    state._fsp--;

            	    if (list_vars==null) list_vars=new ArrayList();
            	    list_vars.add(vars.getTemplate());


            	    }
            	    break;

            	default :
            	    if ( cnt26 >= 1 ) break loop26;
                        EarlyExitException eee =
                            new EarlyExitException(26, input);
                        throw eee;
                }
                cnt26++;
            } while (true);


            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 681:5: -> varDefine(typename=$typeName.stvarRefs=$varstoken=$v.getToken()desc=$text)
            {
                retval.st = templateLib.getInstanceOf("varDefine",
              new STAttrMap().put("typename", (typeName51!=null?typeName51.st:null)).put("varRefs", list_vars).put("token", v.getToken()).put("desc", input.getTokenStream().toString(
              input.getTreeAdaptor().getTokenStartIndex(retval.start),
              input.getTreeAdaptor().getTokenStopIndex(retval.start))));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "varInstance"

    public static class var_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "var"
    // ttcn3tree.g:685:1: var[TType typeTYPE, StringTemplate datatype] : ( id -> varOrConstInitial(typeName=$datatypeleft=$id.textright=nullisComponent=false) | ^(a= ':=' id expr ) -> varOrConstInitial(typeName=$datatypeleft=$id.textright=$expr.stisComponent=isComponent));
    public final ttcn3tree.var_return var(TType typeTYPE, StringTemplate datatype) throws RecognitionException {
        ttcn3tree.var_return retval = new ttcn3tree.var_return();
        retval.start = input.LT(1);

        CommonTree a=null;
        ttcn3tree.id_return id52 = null;

        ttcn3tree.id_return id53 = null;

        ttcn3tree.expr_return expr54 = null;



        boolean isComponent=false;

        try {
            // ttcn3tree.g:689:3: ( id -> varOrConstInitial(typeName=$datatypeleft=$id.textright=nullisComponent=false) | ^(a= ':=' id expr ) -> varOrConstInitial(typeName=$datatypeleft=$id.textright=$expr.stisComponent=isComponent))
            int alt27=2;
            int LA27_0 = input.LA(1);

            if ( (LA27_0==ID) ) {
                alt27=1;
            }
            else if ( (LA27_0==37) ) {
                alt27=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 27, 0, input);

                throw nvae;
            }
            switch (alt27) {
                case 1 :
                    // ttcn3tree.g:689:5: id
                    {
                    pushFollow(FOLLOW_id_in_var1796);
                    id52=id();

                    state._fsp--;


                    	 	 if(isInStatementBlock){
                    	            if( ! checkIsDefined(moduleName, (id52!=null?id52.token:null)) ) {
                        	           	 TType typeVALUE = ((gBlockScope_scope)gBlockScope_stack.peek()).symtbl.newValue((id52!=null?id52.token:null), TSubAttribVALUE.VAR, typeTYPE);
                        			 ((gBlockScope_scope)gBlockScope_stack.peek()).symtbl.addType((id52!=null?id52.token:null), typeVALUE);
                        		    }
                        		 } else {
                        		 	//in componentDef
                        		 	//do nothing now
                        		 }
                    	       


                    // TEMPLATE REWRITE
                    // 700:5: -> varOrConstInitial(typeName=$datatypeleft=$id.textright=nullisComponent=false)
                    {
                        retval.st = templateLib.getInstanceOf("varOrConstInitial",
                      new STAttrMap().put("typeName", datatype).put("left", (id52!=null?id52.text:null)).put("right", null).put("isComponent", false));
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:701:5: ^(a= ':=' id expr )
                    {
                    a=(CommonTree)match(input,37,FOLLOW_37_in_var1836); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_id_in_var1838);
                    id53=id();

                    state._fsp--;

                    pushFollow(FOLLOW_expr_in_var1840);
                    expr54=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 

                    	     if(isInStatementBlock){
                    	        //check for multi-definition
                    	        if( ! checkIsDefined(moduleName, (id53!=null?id53.token:null)) ) {
                    	            //
                        	        	TType typeVALUE = ((gBlockScope_scope)gBlockScope_stack.peek()).symtbl.newValue((id53!=null?id53.token:null), TSubAttribVALUE.VAR, typeTYPE);
                        			((gBlockScope_scope)gBlockScope_stack.peek()).symtbl.addType((id53!=null?id53.token:null), typeVALUE);
                        			
                        			//
                        	        	TType idType = getType(moduleName, (id53!=null?id53.token:null), TAttrib.VALUE, null); 
                        	        	doAssignment(a.getToken(), idType, (expr54!=null?expr54.t:null), false);
                        	        	if((expr54!=null?expr54.t:null).getType()!=null){
                        	        		if((expr54!=null?expr54.t:null).getType().getSubAttrib()==TSubAttribTYPE.COMPONENT){
                        	        			isComponent=true;
                        	        		}
                        	        	}
                        	        }
                        	     } else {
                        	     	//in componentDef
                        	     	 //do nothing now
                        	     }
                    	    


                    // TEMPLATE REWRITE
                    // 724:6: -> varOrConstInitial(typeName=$datatypeleft=$id.textright=$expr.stisComponent=isComponent)
                    {
                        retval.st = templateLib.getInstanceOf("varOrConstInitial",
                      new STAttrMap().put("typeName", datatype).put("left", (id53!=null?id53.text:null)).put("right", (expr54!=null?expr54.st:null)).put("isComponent", isComponent));
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "var"

    public static class functionStatement_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "functionStatement"
    // ttcn3tree.g:727:1: functionStatement : ( basicStatements -> {$basicStatements.st} | behaviourStatements -> {$behaviourStatements.st} | configurationStatements -> {$configurationStatements.st});
    public final ttcn3tree.functionStatement_return functionStatement() throws RecognitionException {
        ttcn3tree.functionStatement_return retval = new ttcn3tree.functionStatement_return();
        retval.start = input.LT(1);

        ttcn3tree.basicStatements_return basicStatements55 = null;

        ttcn3tree.behaviourStatements_return behaviourStatements56 = null;

        ttcn3tree.configurationStatements_return configurationStatements57 = null;


        try {
            // ttcn3tree.g:728:3: ( basicStatements -> {$basicStatements.st} | behaviourStatements -> {$behaviourStatements.st} | configurationStatements -> {$configurationStatements.st})
            int alt28=3;
            alt28 = dfa28.predict(input);
            switch (alt28) {
                case 1 :
                    // ttcn3tree.g:728:5: basicStatements
                    {
                    pushFollow(FOLLOW_basicStatements_in_functionStatement1890);
                    basicStatements55=basicStatements();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 728:21: -> {$basicStatements.st}
                    {
                        retval.st = (basicStatements55!=null?basicStatements55.st:null);
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:729:5: behaviourStatements
                    {
                    pushFollow(FOLLOW_behaviourStatements_in_functionStatement1900);
                    behaviourStatements56=behaviourStatements();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 729:25: -> {$behaviourStatements.st}
                    {
                        retval.st = (behaviourStatements56!=null?behaviourStatements56.st:null);
                    }


                    }
                    break;
                case 3 :
                    // ttcn3tree.g:730:5: configurationStatements
                    {
                    pushFollow(FOLLOW_configurationStatements_in_functionStatement1910);
                    configurationStatements57=configurationStatements();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 730:29: -> {$configurationStatements.st}
                    {
                        retval.st = (configurationStatements57!=null?configurationStatements57.st:null);
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "functionStatement"

    public static class basicStatements_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "basicStatements"
    // ttcn3tree.g:732:1: basicStatements : ( assignment -> {$assignment.st} | loopConstruct -> {$loopConstruct.st} | conditionalConstruct -> {$conditionalConstruct.st} | logStatement -> {$logStatement.st});
    public final ttcn3tree.basicStatements_return basicStatements() throws RecognitionException {
        ttcn3tree.basicStatements_return retval = new ttcn3tree.basicStatements_return();
        retval.start = input.LT(1);

        ttcn3tree.assignment_return assignment58 = null;

        ttcn3tree.loopConstruct_return loopConstruct59 = null;

        ttcn3tree.conditionalConstruct_return conditionalConstruct60 = null;

        ttcn3tree.logStatement_return logStatement61 = null;


        try {
            // ttcn3tree.g:733:2: ( assignment -> {$assignment.st} | loopConstruct -> {$loopConstruct.st} | conditionalConstruct -> {$conditionalConstruct.st} | logStatement -> {$logStatement.st})
            int alt29=4;
            switch ( input.LA(1) ) {
            case 37:
                {
                alt29=1;
                }
                break;
            case 57:
                {
                alt29=2;
                }
                break;
            case 58:
                {
                alt29=3;
                }
                break;
            case 60:
                {
                alt29=4;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 29, 0, input);

                throw nvae;
            }

            switch (alt29) {
                case 1 :
                    // ttcn3tree.g:733:4: assignment
                    {
                    pushFollow(FOLLOW_assignment_in_basicStatements1925);
                    assignment58=assignment();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 733:29: -> {$assignment.st}
                    {
                        retval.st = (assignment58!=null?assignment58.st:null);
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:734:4: loopConstruct
                    {
                    pushFollow(FOLLOW_loopConstruct_in_basicStatements1948);
                    loopConstruct59=loopConstruct();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 734:20: -> {$loopConstruct.st}
                    {
                        retval.st = (loopConstruct59!=null?loopConstruct59.st:null);
                    }


                    }
                    break;
                case 3 :
                    // ttcn3tree.g:735:4: conditionalConstruct
                    {
                    pushFollow(FOLLOW_conditionalConstruct_in_basicStatements1959);
                    conditionalConstruct60=conditionalConstruct();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 735:25: -> {$conditionalConstruct.st}
                    {
                        retval.st = (conditionalConstruct60!=null?conditionalConstruct60.st:null);
                    }


                    }
                    break;
                case 4 :
                    // ttcn3tree.g:736:4: logStatement
                    {
                    pushFollow(FOLLOW_logStatement_in_basicStatements1968);
                    logStatement61=logStatement();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 736:29: -> {$logStatement.st}
                    {
                        retval.st = (logStatement61!=null?logStatement61.st:null);
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "basicStatements"

    public static class behaviourStatements_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "behaviourStatements"
    // ttcn3tree.g:739:1: behaviourStatements : ( functionInstance -> {$functionInstance.st} | testcaseInstance -> {$testcaseInstance.st} | returnStatement -> {$returnStatement.st});
    public final ttcn3tree.behaviourStatements_return behaviourStatements() throws RecognitionException {
        ttcn3tree.behaviourStatements_return retval = new ttcn3tree.behaviourStatements_return();
        retval.start = input.LT(1);

        ttcn3tree.functionInstance_return functionInstance62 = null;

        ttcn3tree.testcaseInstance_return testcaseInstance63 = null;

        ttcn3tree.returnStatement_return returnStatement64 = null;


        try {
            // ttcn3tree.g:740:2: ( functionInstance -> {$functionInstance.st} | testcaseInstance -> {$testcaseInstance.st} | returnStatement -> {$returnStatement.st})
            int alt30=3;
            switch ( input.LA(1) ) {
            case FUNC_CALL:
                {
                alt30=1;
                }
                break;
            case 56:
                {
                alt30=2;
                }
                break;
            case 41:
                {
                alt30=3;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 30, 0, input);

                throw nvae;
            }

            switch (alt30) {
                case 1 :
                    // ttcn3tree.g:740:4: functionInstance
                    {
                    pushFollow(FOLLOW_functionInstance_in_behaviourStatements1995);
                    functionInstance62=functionInstance();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 740:28: -> {$functionInstance.st}
                    {
                        retval.st = (functionInstance62!=null?functionInstance62.st:null);
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:741:4: testcaseInstance
                    {
                    pushFollow(FOLLOW_testcaseInstance_in_behaviourStatements2011);
                    testcaseInstance63=testcaseInstance();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 741:21: -> {$testcaseInstance.st}
                    {
                        retval.st = (testcaseInstance63!=null?testcaseInstance63.st:null);
                    }


                    }
                    break;
                case 3 :
                    // ttcn3tree.g:742:4: returnStatement
                    {
                    pushFollow(FOLLOW_returnStatement_in_behaviourStatements2020);
                    returnStatement64=returnStatement();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 742:29: -> {$returnStatement.st}
                    {
                        retval.st = (returnStatement64!=null?returnStatement64.st:null);
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "behaviourStatements"

    public static class configurationStatements_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "configurationStatements"
    // ttcn3tree.g:745:1: configurationStatements : ( startTCStatement -> startTCStatement(threadName=$startTCStatement.namemodulePrefix=moduleNamefuncName=functype.getName()actualArgs=$startTCStatement.actualArgsrunsOnCompInst=$startTCStatement.runsOnCompInst) | connectStatement -> {$connectStatement.st} | disconnectStatement -> {$disconnectStatement.st} | mapStatement -> {$mapStatement.st} | unmapStatement -> {$unmapStatement.st});
    public final ttcn3tree.configurationStatements_return configurationStatements() throws RecognitionException {
        ttcn3tree.configurationStatements_return retval = new ttcn3tree.configurationStatements_return();
        retval.start = input.LT(1);

        ttcn3tree.startTCStatement_return startTCStatement65 = null;

        ttcn3tree.connectStatement_return connectStatement66 = null;

        ttcn3tree.disconnectStatement_return disconnectStatement67 = null;

        ttcn3tree.mapStatement_return mapStatement68 = null;

        ttcn3tree.unmapStatement_return unmapStatement69 = null;


        try {
            // ttcn3tree.g:746:2: ( startTCStatement -> startTCStatement(threadName=$startTCStatement.namemodulePrefix=moduleNamefuncName=functype.getName()actualArgs=$startTCStatement.actualArgsrunsOnCompInst=$startTCStatement.runsOnCompInst) | connectStatement -> {$connectStatement.st} | disconnectStatement -> {$disconnectStatement.st} | mapStatement -> {$mapStatement.st} | unmapStatement -> {$unmapStatement.st})
            int alt31=5;
            switch ( input.LA(1) ) {
            case 55:
                {
                alt31=1;
                }
                break;
            case 47:
                {
                alt31=2;
                }
                break;
            case 51:
                {
                alt31=3;
                }
                break;
            case 52:
                {
                alt31=4;
                }
                break;
            case 53:
                {
                alt31=5;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 31, 0, input);

                throw nvae;
            }

            switch (alt31) {
                case 1 :
                    // ttcn3tree.g:746:4: startTCStatement
                    {
                    pushFollow(FOLLOW_startTCStatement_in_configurationStatements2044);
                    startTCStatement65=startTCStatement();

                    state._fsp--;


                    	    TType functype = (startTCStatement65!=null?startTCStatement65.functype:null);
                    	  	//save (startTCStatement65!=null?startTCStatement65.st:null)
                    	  	((ttcn3Module_scope)ttcn3Module_stack.peek()).runnableImpls.add((startTCStatement65!=null?startTCStatement65.st:null));
                    	  


                    // TEMPLATE REWRITE
                    // 752:4: -> startTCStatement(threadName=$startTCStatement.namemodulePrefix=moduleNamefuncName=functype.getName()actualArgs=$startTCStatement.actualArgsrunsOnCompInst=$startTCStatement.runsOnCompInst)
                    {
                        retval.st = templateLib.getInstanceOf("startTCStatement",
                      new STAttrMap().put("threadName", (startTCStatement65!=null?startTCStatement65.name:null)).put("modulePrefix", moduleName).put("funcName", functype.getName()).put("actualArgs", (startTCStatement65!=null?startTCStatement65.actualArgs:null)).put("runsOnCompInst", (startTCStatement65!=null?startTCStatement65.runsOnCompInst:null)));
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:753:4: connectStatement
                    {
                    pushFollow(FOLLOW_connectStatement_in_configurationStatements2087);
                    connectStatement66=connectStatement();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 753:21: -> {$connectStatement.st}
                    {
                        retval.st = (connectStatement66!=null?connectStatement66.st:null);
                    }


                    }
                    break;
                case 3 :
                    // ttcn3tree.g:754:4: disconnectStatement
                    {
                    pushFollow(FOLLOW_disconnectStatement_in_configurationStatements2096);
                    disconnectStatement67=disconnectStatement();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 754:24: -> {$disconnectStatement.st}
                    {
                        retval.st = (disconnectStatement67!=null?disconnectStatement67.st:null);
                    }


                    }
                    break;
                case 4 :
                    // ttcn3tree.g:755:4: mapStatement
                    {
                    pushFollow(FOLLOW_mapStatement_in_configurationStatements2105);
                    mapStatement68=mapStatement();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 755:18: -> {$mapStatement.st}
                    {
                        retval.st = (mapStatement68!=null?mapStatement68.st:null);
                    }


                    }
                    break;
                case 5 :
                    // ttcn3tree.g:756:4: unmapStatement
                    {
                    pushFollow(FOLLOW_unmapStatement_in_configurationStatements2115);
                    unmapStatement69=unmapStatement();

                    state._fsp--;



                    // TEMPLATE REWRITE
                    // 756:19: -> {$unmapStatement.st}
                    {
                        retval.st = (unmapStatement69!=null?unmapStatement69.st:null);
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "configurationStatements"

    public static class connectStatement_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "connectStatement"
    // ttcn3tree.g:759:1: connectStatement : ^( 'connect' singleConnectionSpec ) -> {$singleConnectionSpec.st};
    public final ttcn3tree.connectStatement_return connectStatement() throws RecognitionException {
        ttcn3tree.connectStatement_return retval = new ttcn3tree.connectStatement_return();
        retval.start = input.LT(1);

        ttcn3tree.singleConnectionSpec_return singleConnectionSpec70 = null;


        try {
            // ttcn3tree.g:760:2: ( ^( 'connect' singleConnectionSpec ) -> {$singleConnectionSpec.st})
            // ttcn3tree.g:760:4: ^( 'connect' singleConnectionSpec )
            {
            match(input,47,FOLLOW_47_in_connectStatement2131); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_singleConnectionSpec_in_connectStatement2133);
            singleConnectionSpec70=singleConnectionSpec();

            state._fsp--;


            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 760:38: -> {$singleConnectionSpec.st}
            {
                retval.st = (singleConnectionSpec70!=null?singleConnectionSpec70.st:null);
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "connectStatement"

    public static class disconnectStatement_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "disconnectStatement"
    // ttcn3tree.g:762:1: disconnectStatement : ^( 'disconnect' singleOrMultiConnectionSpec ) -> {$singleOrMultiConnectionSpec.st};
    public final ttcn3tree.disconnectStatement_return disconnectStatement() throws RecognitionException {
        ttcn3tree.disconnectStatement_return retval = new ttcn3tree.disconnectStatement_return();
        retval.start = input.LT(1);

        ttcn3tree.singleOrMultiConnectionSpec_return singleOrMultiConnectionSpec71 = null;


        try {
            // ttcn3tree.g:763:2: ( ^( 'disconnect' singleOrMultiConnectionSpec ) -> {$singleOrMultiConnectionSpec.st})
            // ttcn3tree.g:763:4: ^( 'disconnect' singleOrMultiConnectionSpec )
            {
            match(input,51,FOLLOW_51_in_disconnectStatement2149); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_singleOrMultiConnectionSpec_in_disconnectStatement2151);
            singleOrMultiConnectionSpec71=singleOrMultiConnectionSpec();

            state._fsp--;


            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 763:48: -> {$singleOrMultiConnectionSpec.st}
            {
                retval.st = (singleOrMultiConnectionSpec71!=null?singleOrMultiConnectionSpec71.st:null);
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "disconnectStatement"

    public static class singleConnectionSpec_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "singleConnectionSpec"
    // ttcn3tree.g:765:1: singleConnectionSpec : ^( SINGLE_CONNECT portRef portRef ) ;
    public final ttcn3tree.singleConnectionSpec_return singleConnectionSpec() throws RecognitionException {
        ttcn3tree.singleConnectionSpec_return retval = new ttcn3tree.singleConnectionSpec_return();
        retval.start = input.LT(1);

        try {
            // ttcn3tree.g:766:2: ( ^( SINGLE_CONNECT portRef portRef ) )
            // ttcn3tree.g:766:4: ^( SINGLE_CONNECT portRef portRef )
            {
            match(input,SINGLE_CONNECT,FOLLOW_SINGLE_CONNECT_in_singleConnectionSpec2167); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_portRef_in_singleConnectionSpec2169);
            portRef();

            state._fsp--;

            pushFollow(FOLLOW_portRef_in_singleConnectionSpec2171);
            portRef();

            state._fsp--;


            match(input, Token.UP, null); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "singleConnectionSpec"

    public static class portRef_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "portRef"
    // ttcn3tree.g:768:1: portRef : ^( PORT_REF componentRef port ) ;
    public final ttcn3tree.portRef_return portRef() throws RecognitionException {
        ttcn3tree.portRef_return retval = new ttcn3tree.portRef_return();
        retval.start = input.LT(1);

        try {
            // ttcn3tree.g:769:2: ( ^( PORT_REF componentRef port ) )
            // ttcn3tree.g:769:4: ^( PORT_REF componentRef port )
            {
            match(input,PORT_REF,FOLLOW_PORT_REF_in_portRef2183); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_componentRef_in_portRef2185);
            componentRef();

            state._fsp--;

            pushFollow(FOLLOW_port_in_portRef2187);
            port();

            state._fsp--;


            match(input, Token.UP, null); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "portRef"

    public static class componentRef_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "componentRef"
    // ttcn3tree.g:771:1: componentRef : ( componentOrDefaultReference | 'system' | 'self' | 'mtc' );
    public final ttcn3tree.componentRef_return componentRef() throws RecognitionException {
        ttcn3tree.componentRef_return retval = new ttcn3tree.componentRef_return();
        retval.start = input.LT(1);

        try {
            // ttcn3tree.g:772:2: ( componentOrDefaultReference | 'system' | 'self' | 'mtc' )
            int alt32=4;
            switch ( input.LA(1) ) {
            case FIELD_ACCESS:
            case ID:
                {
                alt32=1;
                }
                break;
            case 45:
                {
                alt32=2;
                }
                break;
            case 49:
                {
                alt32=3;
                }
                break;
            case 50:
                {
                alt32=4;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 32, 0, input);

                throw nvae;
            }

            switch (alt32) {
                case 1 :
                    // ttcn3tree.g:772:4: componentOrDefaultReference
                    {
                    pushFollow(FOLLOW_componentOrDefaultReference_in_componentRef2198);
                    componentOrDefaultReference();

                    state._fsp--;


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:773:4: 'system'
                    {
                    match(input,45,FOLLOW_45_in_componentRef2204); 

                    }
                    break;
                case 3 :
                    // ttcn3tree.g:774:4: 'self'
                    {
                    match(input,49,FOLLOW_49_in_componentRef2210); 

                    }
                    break;
                case 4 :
                    // ttcn3tree.g:775:4: 'mtc'
                    {
                    match(input,50,FOLLOW_50_in_componentRef2216); 

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "componentRef"

    public static class port_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "port"
    // ttcn3tree.g:777:1: port : portIdentifier ;
    public final ttcn3tree.port_return port() throws RecognitionException {
        ttcn3tree.port_return retval = new ttcn3tree.port_return();
        retval.start = input.LT(1);

        try {
            // ttcn3tree.g:778:2: ( portIdentifier )
            // ttcn3tree.g:778:4: portIdentifier
            {
            pushFollow(FOLLOW_portIdentifier_in_port2226);
            portIdentifier();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "port"

    public static class portIdentifier_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "portIdentifier"
    // ttcn3tree.g:780:1: portIdentifier : id ;
    public final ttcn3tree.portIdentifier_return portIdentifier() throws RecognitionException {
        ttcn3tree.portIdentifier_return retval = new ttcn3tree.portIdentifier_return();
        retval.start = input.LT(1);

        try {
            // ttcn3tree.g:781:2: ( id )
            // ttcn3tree.g:781:4: id
            {
            pushFollow(FOLLOW_id_in_portIdentifier2236);
            id();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "portIdentifier"

    public static class singleOrMultiConnectionSpec_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "singleOrMultiConnectionSpec"
    // ttcn3tree.g:783:1: singleOrMultiConnectionSpec : singleConnectionSpec -> {$singleConnectionSpec.st};
    public final ttcn3tree.singleOrMultiConnectionSpec_return singleOrMultiConnectionSpec() throws RecognitionException {
        ttcn3tree.singleOrMultiConnectionSpec_return retval = new ttcn3tree.singleOrMultiConnectionSpec_return();
        retval.start = input.LT(1);

        ttcn3tree.singleConnectionSpec_return singleConnectionSpec72 = null;


        try {
            // ttcn3tree.g:784:2: ( singleConnectionSpec -> {$singleConnectionSpec.st})
            // ttcn3tree.g:784:4: singleConnectionSpec
            {
            pushFollow(FOLLOW_singleConnectionSpec_in_singleOrMultiConnectionSpec2246);
            singleConnectionSpec72=singleConnectionSpec();

            state._fsp--;



            // TEMPLATE REWRITE
            // 784:25: -> {$singleConnectionSpec.st}
            {
                retval.st = (singleConnectionSpec72!=null?singleConnectionSpec72.st:null);
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "singleOrMultiConnectionSpec"

    public static class mapStatement_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "mapStatement"
    // ttcn3tree.g:787:1: mapStatement : ^( 'map' singleConnectionSpec ) -> {$singleConnectionSpec.st};
    public final ttcn3tree.mapStatement_return mapStatement() throws RecognitionException {
        ttcn3tree.mapStatement_return retval = new ttcn3tree.mapStatement_return();
        retval.start = input.LT(1);

        ttcn3tree.singleConnectionSpec_return singleConnectionSpec73 = null;


        try {
            // ttcn3tree.g:788:2: ( ^( 'map' singleConnectionSpec ) -> {$singleConnectionSpec.st})
            // ttcn3tree.g:788:4: ^( 'map' singleConnectionSpec )
            {
            match(input,52,FOLLOW_52_in_mapStatement2262); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_singleConnectionSpec_in_mapStatement2264);
            singleConnectionSpec73=singleConnectionSpec();

            state._fsp--;


            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 788:34: -> {$singleConnectionSpec.st}
            {
                retval.st = (singleConnectionSpec73!=null?singleConnectionSpec73.st:null);
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "mapStatement"

    public static class unmapStatement_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "unmapStatement"
    // ttcn3tree.g:791:1: unmapStatement : ^( 'unmap' ( singleOrMultiConnectionSpec )? ) ;
    public final ttcn3tree.unmapStatement_return unmapStatement() throws RecognitionException {
        ttcn3tree.unmapStatement_return retval = new ttcn3tree.unmapStatement_return();
        retval.start = input.LT(1);

        try {
            // ttcn3tree.g:792:2: ( ^( 'unmap' ( singleOrMultiConnectionSpec )? ) )
            // ttcn3tree.g:792:4: ^( 'unmap' ( singleOrMultiConnectionSpec )? )
            {
            match(input,53,FOLLOW_53_in_unmapStatement2281); 

            if ( input.LA(1)==Token.DOWN ) {
                match(input, Token.DOWN, null); 
                // ttcn3tree.g:792:14: ( singleOrMultiConnectionSpec )?
                int alt33=2;
                int LA33_0 = input.LA(1);

                if ( (LA33_0==SINGLE_CONNECT) ) {
                    alt33=1;
                }
                switch (alt33) {
                    case 1 :
                        // ttcn3tree.g:792:15: singleOrMultiConnectionSpec
                        {
                        pushFollow(FOLLOW_singleOrMultiConnectionSpec_in_unmapStatement2284);
                        singleOrMultiConnectionSpec();

                        state._fsp--;


                        }
                        break;

                }


                match(input, Token.UP, null); 
            }

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "unmapStatement"

    public static class startTCStatement_return extends TreeRuleReturnScope {
        public String name;
        public TType functype;
        public List actualArgs;
        public String runsOnCompInst;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "startTCStatement"
    // ttcn3tree.g:800:1: startTCStatement returns [String name, TType functype, List actualArgs, String runsOnCompInst] : ^( 'start' componentOrDefaultReference functionInstance ) ;
    public final ttcn3tree.startTCStatement_return startTCStatement() throws RecognitionException {
        ttcn3tree.startTCStatement_return retval = new ttcn3tree.startTCStatement_return();
        retval.start = input.LT(1);

        ttcn3tree.componentOrDefaultReference_return componentOrDefaultReference74 = null;

        ttcn3tree.functionInstance_return functionInstance75 = null;



        	startTCInstance = null;
        	FunctionType ftype = null;

        try {
            // ttcn3tree.g:808:2: ( ^( 'start' componentOrDefaultReference functionInstance ) )
            // ttcn3tree.g:808:4: ^( 'start' componentOrDefaultReference functionInstance )
            {
            match(input,55,FOLLOW_55_in_startTCStatement2314); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_componentOrDefaultReference_in_startTCStatement2316);
            componentOrDefaultReference74=componentOrDefaultReference();

            state._fsp--;

             startTCInstance = (componentOrDefaultReference74!=null?componentOrDefaultReference74.st:null);
            pushFollow(FOLLOW_functionInstance_in_startTCStatement2320);
            functionInstance75=functionInstance();

            state._fsp--;


            match(input, Token.UP, null); 

            		ftype=(FunctionType)(functionInstance75!=null?functionInstance75.functype:null);
            		
            		retval.name = (componentOrDefaultReference74!=null?componentOrDefaultReference74.st:null).toString();
            		retval.functype = ftype;
            		retval.actualArgs = (functionInstance75!=null?functionInstance75.actualArgs:null);
            		
            		String runsOnComp = ftype.getRunsOnComp();
            		retval.runsOnCompInst = startTCInstance.toString();
            		

            }


            	startTCInstance = null;

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "startTCStatement"

    public static class componentOrDefaultReference_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "componentOrDefaultReference"
    // ttcn3tree.g:821:1: componentOrDefaultReference returns [TType t] : variableRef -> {$variableRef.st};
    public final ttcn3tree.componentOrDefaultReference_return componentOrDefaultReference() throws RecognitionException {
        ttcn3tree.componentOrDefaultReference_return retval = new ttcn3tree.componentOrDefaultReference_return();
        retval.start = input.LT(1);

        ttcn3tree.variableRef_return variableRef76 = null;


        try {
            // ttcn3tree.g:822:2: ( variableRef -> {$variableRef.st})
            // ttcn3tree.g:822:4: variableRef
            {
            pushFollow(FOLLOW_variableRef_in_componentOrDefaultReference2341);
            variableRef76=variableRef();

            state._fsp--;

            retval.t = (variableRef76!=null?variableRef76.t:null);


            // TEMPLATE REWRITE
            // 822:40: -> {$variableRef.st}
            {
                retval.st = (variableRef76!=null?variableRef76.st:null);
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "componentOrDefaultReference"

    public static class testcaseInstance_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "testcaseInstance"
    // ttcn3tree.g:826:1: testcaseInstance returns [TType t] : ^( 'execute' id ( testcaseActualParList[formalArgs, $id.token] )? ) -> testcaseCall(name=$id.textargs=$testcaseActualParList.argsargsType=formalArgsTypeNamerunsOnType=runsOnTyperunsOnSystemType=runsOnSystemTypetoken=$id.tokendesc=$text);
    public final ttcn3tree.testcaseInstance_return testcaseInstance() throws RecognitionException {
        ttcn3tree.testcaseInstance_return retval = new ttcn3tree.testcaseInstance_return();
        retval.start = input.LT(1);

        ttcn3tree.id_return id77 = null;

        ttcn3tree.testcaseActualParList_return testcaseActualParList78 = null;



        	String runsOnType=null;
        	String runsOnSystemType=null;
        	LinkedList<String> formalArgsTypeName=null;
        	Map<String, TType> formalArgs=null;

        try {
            // ttcn3tree.g:834:2: ( ^( 'execute' id ( testcaseActualParList[formalArgs, $id.token] )? ) -> testcaseCall(name=$id.textargs=$testcaseActualParList.argsargsType=formalArgsTypeNamerunsOnType=runsOnTyperunsOnSystemType=runsOnSystemTypetoken=$id.tokendesc=$text))
            // ttcn3tree.g:834:4: ^( 'execute' id ( testcaseActualParList[formalArgs, $id.token] )? )
            {
            match(input,56,FOLLOW_56_in_testcaseInstance2370); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_id_in_testcaseInstance2372);
            id77=id();

            state._fsp--;


            	            TType tcase = getType(moduleName, (id77!=null?id77.token:null), TAttrib.TESTCASE, null);
                                if(tcase==null) {
                                	System.out.println("Undefined testcase="+(id77!=null?id77.text:null));
                                    return null;
                                }
                                
                                /** start check runs on */
                                TestcaseType tctype = (TestcaseType)tcase;
                                runsOnType = tctype.getRunsOnComp();
                                runsOnSystemType = tctype.getSystemOnComp();
                                /** end */
                                
                            /* For check the parameters TYPEs*/
                            formalArgs=tcase.getSubTable();
                            
                            // The testcase's return type is allways the VerdictType
                            retval.t = newValue((id77!=null?id77.token:null), TSubAttribVALUE.VAR, tcase.getType());
            	 
            // ttcn3tree.g:854:3: ( testcaseActualParList[formalArgs, $id.token] )?
            int alt34=2;
            int LA34_0 = input.LA(1);

            if ( (LA34_0==ACTUAL_ARGS) ) {
                alt34=1;
            }
            switch (alt34) {
                case 1 :
                    // ttcn3tree.g:854:3: testcaseActualParList[formalArgs, $id.token]
                    {
                    pushFollow(FOLLOW_testcaseActualParList_in_testcaseInstance2381);
                    testcaseActualParList78=testcaseActualParList(formalArgs, (id77!=null?id77.token:null));

                    state._fsp--;


                    }
                    break;

            }


                                formalArgsTypeName = new LinkedList<String>();
                                if((testcaseActualParList78!=null?testcaseActualParList78.args:null)!=null&&formalArgs!=null) {
                                    Iterator<String> iter=formalArgs.keySet().iterator();
                                    for(;iter.hasNext();) {
                                        String typename = formalArgs.get(iter.next()).getType().getName();
                                        formalArgsTypeName.addLast(typename);
                                    }
                                }
            	 

            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 866:3: -> testcaseCall(name=$id.textargs=$testcaseActualParList.argsargsType=formalArgsTypeNamerunsOnType=runsOnTyperunsOnSystemType=runsOnSystemTypetoken=$id.tokendesc=$text)
            {
                retval.st = templateLib.getInstanceOf("testcaseCall",
              new STAttrMap().put("name", (id77!=null?id77.text:null)).put("args", (testcaseActualParList78!=null?testcaseActualParList78.args:null)).put("argsType", formalArgsTypeName).put("runsOnType", runsOnType).put("runsOnSystemType", runsOnSystemType).put("token", (id77!=null?id77.token:null)).put("desc", input.getTokenStream().toString(
              input.getTreeAdaptor().getTokenStartIndex(retval.start),
              input.getTreeAdaptor().getTokenStopIndex(retval.start))));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "testcaseInstance"

    public static class testcaseActualParList_return extends TreeRuleReturnScope {
        public List args;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "testcaseActualParList"
    // ttcn3tree.g:868:1: testcaseActualParList[Map<String, TType> formalArgs, Token token] returns [List args] : actualArgs[$formalArgs, $token] ;
    public final ttcn3tree.testcaseActualParList_return testcaseActualParList(Map<String, TType> formalArgs, Token token) throws RecognitionException {
        ttcn3tree.testcaseActualParList_return retval = new ttcn3tree.testcaseActualParList_return();
        retval.start = input.LT(1);

        ttcn3tree.actualArgs_return actualArgs79 = null;


        try {
            // ttcn3tree.g:869:2: ( actualArgs[$formalArgs, $token] )
            // ttcn3tree.g:869:4: actualArgs[$formalArgs, $token]
            {
            pushFollow(FOLLOW_actualArgs_in_testcaseActualParList2447);
            actualArgs79=actualArgs(formalArgs, token);

            state._fsp--;

            retval.args = (actualArgs79!=null?actualArgs79.args:null);

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "testcaseActualParList"

    public static class loopConstruct_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "loopConstruct"
    // ttcn3tree.g:872:1: loopConstruct : ^( 'for' initExpr conditionExpr stepExpr statementBlock[null] ) ;
    public final ttcn3tree.loopConstruct_return loopConstruct() throws RecognitionException {
        ttcn3tree.loopConstruct_return retval = new ttcn3tree.loopConstruct_return();
        retval.start = input.LT(1);

        try {
            // ttcn3tree.g:873:3: ( ^( 'for' initExpr conditionExpr stepExpr statementBlock[null] ) )
            // ttcn3tree.g:873:5: ^( 'for' initExpr conditionExpr stepExpr statementBlock[null] )
            {
            match(input,57,FOLLOW_57_in_loopConstruct2465); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_initExpr_in_loopConstruct2467);
            initExpr();

            state._fsp--;

            pushFollow(FOLLOW_conditionExpr_in_loopConstruct2469);
            conditionExpr();

            state._fsp--;

            pushFollow(FOLLOW_stepExpr_in_loopConstruct2471);
            stepExpr();

            state._fsp--;

            pushFollow(FOLLOW_statementBlock_in_loopConstruct2473);
            statementBlock(null);

            state._fsp--;


            match(input, Token.UP, null); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "loopConstruct"

    public static class initExpr_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "initExpr"
    // ttcn3tree.g:876:1: initExpr : ( varInstance | assignment );
    public final ttcn3tree.initExpr_return initExpr() throws RecognitionException {
        ttcn3tree.initExpr_return retval = new ttcn3tree.initExpr_return();
        retval.start = input.LT(1);

        try {
            // ttcn3tree.g:877:3: ( varInstance | assignment )
            int alt35=2;
            int LA35_0 = input.LA(1);

            if ( (LA35_0==46) ) {
                alt35=1;
            }
            else if ( (LA35_0==37) ) {
                alt35=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 35, 0, input);

                throw nvae;
            }
            switch (alt35) {
                case 1 :
                    // ttcn3tree.g:877:5: varInstance
                    {
                    pushFollow(FOLLOW_varInstance_in_initExpr2490);
                    varInstance();

                    state._fsp--;


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:878:5: assignment
                    {
                    pushFollow(FOLLOW_assignment_in_initExpr2497);
                    assignment();

                    state._fsp--;


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "initExpr"

    public static class conditionExpr_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "conditionExpr"
    // ttcn3tree.g:881:1: conditionExpr : boolExpr ;
    public final ttcn3tree.conditionExpr_return conditionExpr() throws RecognitionException {
        ttcn3tree.conditionExpr_return retval = new ttcn3tree.conditionExpr_return();
        retval.start = input.LT(1);

        try {
            // ttcn3tree.g:882:3: ( boolExpr )
            // ttcn3tree.g:882:5: boolExpr
            {
            pushFollow(FOLLOW_boolExpr_in_conditionExpr2510);
            boolExpr();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "conditionExpr"

    public static class stepExpr_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "stepExpr"
    // ttcn3tree.g:885:1: stepExpr : assignment ;
    public final ttcn3tree.stepExpr_return stepExpr() throws RecognitionException {
        ttcn3tree.stepExpr_return retval = new ttcn3tree.stepExpr_return();
        retval.start = input.LT(1);

        try {
            // ttcn3tree.g:886:3: ( assignment )
            // ttcn3tree.g:886:5: assignment
            {
            pushFollow(FOLLOW_assignment_in_stepExpr2524);
            assignment();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "stepExpr"

    public static class conditionalConstruct_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "conditionalConstruct"
    // ttcn3tree.g:889:1: conditionalConstruct : ^( 'if' boolExpr statementBlock[null] ( statementBlock[null] )? ) ;
    public final ttcn3tree.conditionalConstruct_return conditionalConstruct() throws RecognitionException {
        ttcn3tree.conditionalConstruct_return retval = new ttcn3tree.conditionalConstruct_return();
        retval.start = input.LT(1);

        try {
            // ttcn3tree.g:890:3: ( ^( 'if' boolExpr statementBlock[null] ( statementBlock[null] )? ) )
            // ttcn3tree.g:890:5: ^( 'if' boolExpr statementBlock[null] ( statementBlock[null] )? )
            {
            match(input,58,FOLLOW_58_in_conditionalConstruct2540); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_boolExpr_in_conditionalConstruct2542);
            boolExpr();

            state._fsp--;

            pushFollow(FOLLOW_statementBlock_in_conditionalConstruct2544);
            statementBlock(null);

            state._fsp--;

            // ttcn3tree.g:890:43: ( statementBlock[null] )?
            int alt36=2;
            int LA36_0 = input.LA(1);

            if ( (LA36_0==BLOCK) ) {
                alt36=1;
            }
            switch (alt36) {
                case 1 :
                    // ttcn3tree.g:890:43: statementBlock[null]
                    {
                    pushFollow(FOLLOW_statementBlock_in_conditionalConstruct2547);
                    statementBlock(null);

                    state._fsp--;


                    }
                    break;

            }


            match(input, Token.UP, null); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "conditionalConstruct"

    public static class logStatement_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "logStatement"
    // ttcn3tree.g:893:1: logStatement : ^(l= 'log' ( actualArgs[null, null] )? ) -> logStatement(args=$actualArgs.argstoken=$l.getToken()desc=$text);
    public final ttcn3tree.logStatement_return logStatement() throws RecognitionException {
        ttcn3tree.logStatement_return retval = new ttcn3tree.logStatement_return();
        retval.start = input.LT(1);

        CommonTree l=null;
        ttcn3tree.actualArgs_return actualArgs80 = null;


        try {
            // ttcn3tree.g:894:3: ( ^(l= 'log' ( actualArgs[null, null] )? ) -> logStatement(args=$actualArgs.argstoken=$l.getToken()desc=$text))
            // ttcn3tree.g:894:5: ^(l= 'log' ( actualArgs[null, null] )? )
            {
            l=(CommonTree)match(input,60,FOLLOW_60_in_logStatement2567); 

            if ( input.LA(1)==Token.DOWN ) {
                match(input, Token.DOWN, null); 
                // ttcn3tree.g:894:16: ( actualArgs[null, null] )?
                int alt37=2;
                int LA37_0 = input.LA(1);

                if ( (LA37_0==ACTUAL_ARGS) ) {
                    alt37=1;
                }
                switch (alt37) {
                    case 1 :
                        // ttcn3tree.g:894:18: actualArgs[null, null]
                        {
                        pushFollow(FOLLOW_actualArgs_in_logStatement2571);
                        actualArgs80=actualArgs(null, null);

                        state._fsp--;


                        }
                        break;

                }


                match(input, Token.UP, null); 
            }


            // TEMPLATE REWRITE
            // 895:5: -> logStatement(args=$actualArgs.argstoken=$l.getToken()desc=$text)
            {
                retval.st = templateLib.getInstanceOf("logStatement",
              new STAttrMap().put("args", (actualArgs80!=null?actualArgs80.args:null)).put("token", l.getToken()).put("desc", input.getTokenStream().toString(
              input.getTreeAdaptor().getTokenStartIndex(retval.start),
              input.getTreeAdaptor().getTokenStopIndex(retval.start))));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "logStatement"

    public static class functionInstance_return extends TreeRuleReturnScope {
        public TType t;
        public TType functype;
        public List actualArgs;
        public String runsOnInst;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "functionInstance"
    // ttcn3tree.g:899:1: functionInstance returns [TType t, TType functype, List actualArgs, String runsOnInst] : ^( FUNC_CALL id ( actualArgs[formalArgs, $id.token] )? ) -> functionCall(name=$id.textargs=$actualArgs.argsargsType=formalArgsTypeNamerunsOnInst=runsOnInstreturnType=\"XXX\"token=$id.tokendesc=$text);
    public final ttcn3tree.functionInstance_return functionInstance() throws RecognitionException {
        ttcn3tree.functionInstance_return retval = new ttcn3tree.functionInstance_return();
        retval.start = input.LT(1);

        ttcn3tree.id_return id81 = null;

        ttcn3tree.actualArgs_return actualArgs82 = null;



            LinkedList<String> formalArgsTypeName=null;
            String runsOnInst = null;
            Map<String, TType> formalArgs = null;

        try {
            // ttcn3tree.g:905:3: ( ^( FUNC_CALL id ( actualArgs[formalArgs, $id.token] )? ) -> functionCall(name=$id.textargs=$actualArgs.argsargsType=formalArgsTypeNamerunsOnInst=runsOnInstreturnType=\"XXX\"token=$id.tokendesc=$text))
            // ttcn3tree.g:905:5: ^( FUNC_CALL id ( actualArgs[formalArgs, $id.token] )? )
            {
            match(input,FUNC_CALL,FOLLOW_FUNC_CALL_in_functionInstance2625); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_id_in_functionInstance2627);
            id81=id();

            state._fsp--;


            	            TType tfunc = getType(moduleName, (id81!=null?id81.token:null), TAttrib.FUNCTION, null);
                                if(tfunc==null) {
                                	System.out.println("Undefined testcase="+(id81!=null?id81.text:null));
                                    return null;
                                }
                                
                                if(startTCInstance!=null){
                                	runsOnInst = startTCInstance.toString();
                                }
                                /** start check runs on */
                                else if(runsOnComp!=null && runsOnComp.equals(((FunctionType)tfunc).getRunsOnComp())) {
                                	runsOnInst = "self";
                                }
                                retval.runsOnInst = runsOnInst;
                                /** end */
                                
                            /* For check the parameters TYPEs*/
                            formalArgs=tfunc.getSubTable();
                            
                            // tfunc.getType() is the function return type
                            if(tfunc.getType()!=null) {
                            	retval.t = newValue((id81!=null?id81.token:null), TSubAttribVALUE.VAR, tfunc.getType());
                            }
                            retval.functype = tfunc;
                        
            // ttcn3tree.g:932:13: ( actualArgs[formalArgs, $id.token] )?
            int alt38=2;
            int LA38_0 = input.LA(1);

            if ( (LA38_0==ACTUAL_ARGS) ) {
                alt38=1;
            }
            switch (alt38) {
                case 1 :
                    // ttcn3tree.g:932:15: actualArgs[formalArgs, $id.token]
                    {
                    pushFollow(FOLLOW_actualArgs_in_functionInstance2654);
                    actualArgs82=actualArgs(formalArgs, (id81!=null?id81.token:null));

                    state._fsp--;


                                        formalArgsTypeName = new LinkedList<String>();
                                        if((actualArgs82!=null?actualArgs82.args:null)!=null&&formalArgs!=null) {
                                            Iterator<String> iter=formalArgs.keySet().iterator();
                                            for(;iter.hasNext();) {
                                                String typename = formalArgs.get(iter.next()).getType().getName();
                                                formalArgsTypeName.addLast(typename);
                                            }
                                        }
                                        
                                        retval.actualArgs = (actualArgs82!=null?actualArgs82.args:null);
                                    

                    }
                    break;

            }


            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 947:6: -> functionCall(name=$id.textargs=$actualArgs.argsargsType=formalArgsTypeNamerunsOnInst=runsOnInstreturnType=\"XXX\"token=$id.tokendesc=$text)
            {
                retval.st = templateLib.getInstanceOf("functionCall",
              new STAttrMap().put("name", (id81!=null?id81.text:null)).put("args", (actualArgs82!=null?actualArgs82.args:null)).put("argsType", formalArgsTypeName).put("runsOnInst", runsOnInst).put("returnType", "XXX").put("token", (id81!=null?id81.token:null)).put("desc", input.getTokenStream().toString(
              input.getTreeAdaptor().getTokenStartIndex(retval.start),
              input.getTreeAdaptor().getTokenStopIndex(retval.start))));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "functionInstance"

    public static class actualArgs_return extends TreeRuleReturnScope {
        public List args;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "actualArgs"
    // ttcn3tree.g:951:1: actualArgs[Map<String, TType> argsTypes, Token token] returns [List args] : ^( ACTUAL_ARGS (a+= expr )+ ) ;
    public final ttcn3tree.actualArgs_return actualArgs(Map<String, TType> argsTypes, Token token) throws RecognitionException {
        ttcn3tree.actualArgs_return retval = new ttcn3tree.actualArgs_return();
        retval.start = input.LT(1);

        List list_a=null;
        ttcn3tree.expr_return a = null;
         a = null;

            LinkedList<TType> argValueList = new LinkedList<TType>();

        try {
            // ttcn3tree.g:955:3: ( ^( ACTUAL_ARGS (a+= expr )+ ) )
            // ttcn3tree.g:955:5: ^( ACTUAL_ARGS (a+= expr )+ )
            {
            match(input,ACTUAL_ARGS,FOLLOW_ACTUAL_ARGS_in_actualArgs2771); 

            match(input, Token.DOWN, null); 
            // ttcn3tree.g:955:20: (a+= expr )+
            int cnt39=0;
            loop39:
            do {
                int alt39=2;
                alt39 = dfa39.predict(input);
                switch (alt39) {
            	case 1 :
            	    // ttcn3tree.g:955:22: a+= expr
            	    {
            	    pushFollow(FOLLOW_expr_in_actualArgs2777);
            	    a=expr();

            	    state._fsp--;

            	    if (list_a==null) list_a=new ArrayList();
            	    list_a.add(a.getTemplate());

            	     argValueList.addLast((a!=null?a.t:null)); 

            	    }
            	    break;

            	default :
            	    if ( cnt39 >= 1 ) break loop39;
                        EarlyExitException eee =
                            new EarlyExitException(39, input);
                        throw eee;
                }
                cnt39++;
            } while (true);


            match(input, Token.UP, null); 

            	        retval.args =null;
            	        if(token!=null) {
                                if(true==checkActualArg(token, argsTypes, argValueList)) {
                                    retval.args =list_a;
                                } else {
                                    logError(token, "checkActualArg fail.");
                                }
                            } else {    //for log function only.
                                retval.args =list_a;
                            }
            	        

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "actualArgs"

    public static class returnStatement_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "returnStatement"
    // ttcn3tree.g:970:1: returnStatement : ^(r= 'return' ( expr )? ) -> returnStatement(returnType=currentFuncReturnTypeSTexpr=$expr.sttoken=$r.getToken()desc=$text);
    public final ttcn3tree.returnStatement_return returnStatement() throws RecognitionException {
        ttcn3tree.returnStatement_return retval = new ttcn3tree.returnStatement_return();
        retval.start = input.LT(1);

        CommonTree r=null;
        ttcn3tree.expr_return expr83 = null;


        try {
            // ttcn3tree.g:971:3: ( ^(r= 'return' ( expr )? ) -> returnStatement(returnType=currentFuncReturnTypeSTexpr=$expr.sttoken=$r.getToken()desc=$text))
            // ttcn3tree.g:971:5: ^(r= 'return' ( expr )? )
            {
            r=(CommonTree)match(input,41,FOLLOW_41_in_returnStatement2812); 

            if ( input.LA(1)==Token.DOWN ) {
                match(input, Token.DOWN, null); 
                // ttcn3tree.g:971:19: ( expr )?
                int alt40=2;
                alt40 = dfa40.predict(input);
                switch (alt40) {
                    case 1 :
                        // ttcn3tree.g:971:21: expr
                        {
                        pushFollow(FOLLOW_expr_in_returnStatement2816);
                        expr83=expr();

                        state._fsp--;


                        }
                        break;

                }


                match(input, Token.UP, null); 
            }

            	        if(!isInFunctionDef) {
            	            logError(r.token, "\"return\" statement must be placed in function definition space.");
            	        } else {
            	            if((expr83!=null?expr83.t:null)==null) {
            	                if(currentFuncReturnType!=null){
            	                    logError(r.token, "Return statement must present a expression.");
            	                }
            	            }
            	            if(currentFuncReturnType==null) {
            	                if((expr83!=null?expr83.t:null)!=null){
            	                    logError(r.token, "Return statement cannot present a expression.");
            	                }
            	            }
            	            if(currentFuncReturnType!=null && (expr83!=null?expr83.t:null)!=null) {
                	            if(currentFuncReturnType.getSubAttrib() != (expr83!=null?expr83.t:null).getType().getSubAttrib()) {
                	                logError(r.token, "The returned type of expression is incompatibility with the return type of function \""+currentFuncName+"\".");
                	                logError(r.token, "Expression return type=%s, function return type=%s", currentFuncReturnType.getSubAttrib(), (expr83!=null?expr83.t:null).getType().getSubAttrib());
                	            }
                	        }
            	        }
            	    


            // TEMPLATE REWRITE
            // 994:5: -> returnStatement(returnType=currentFuncReturnTypeSTexpr=$expr.sttoken=$r.getToken()desc=$text)
            {
                retval.st = templateLib.getInstanceOf("returnStatement",
              new STAttrMap().put("returnType", currentFuncReturnTypeST).put("expr", (expr83!=null?expr83.st:null)).put("token", r.getToken()).put("desc", input.getTokenStream().toString(
              input.getTreeAdaptor().getTokenStartIndex(retval.start),
              input.getTreeAdaptor().getTokenStopIndex(retval.start))));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "returnStatement"

    public static class assignment_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "assignment"
    // ttcn3tree.g:997:1: assignment : ^(st= ':=' variableRef expr ) -> varAssignment(left=$variableRef.stright=$expr.sttoken=$st.tokendesc=$text);
    public final ttcn3tree.assignment_return assignment() throws RecognitionException {
        ttcn3tree.assignment_return retval = new ttcn3tree.assignment_return();
        retval.start = input.LT(1);

        CommonTree st=null;
        ttcn3tree.variableRef_return variableRef84 = null;

        ttcn3tree.expr_return expr85 = null;


        try {
            // ttcn3tree.g:998:3: ( ^(st= ':=' variableRef expr ) -> varAssignment(left=$variableRef.stright=$expr.sttoken=$st.tokendesc=$text))
            // ttcn3tree.g:998:5: ^(st= ':=' variableRef expr )
            {
            st=(CommonTree)match(input,37,FOLLOW_37_in_assignment2874); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_variableRef_in_assignment2876);
            variableRef84=variableRef();

            state._fsp--;

            pushFollow(FOLLOW_expr_in_assignment2878);
            expr85=expr();

            state._fsp--;


            match(input, Token.UP, null); 

            	        doAssignment(st.getToken(), (variableRef84!=null?variableRef84.t:null), (expr85!=null?expr85.t:null), false);
            	    


            // TEMPLATE REWRITE
            // 1002:6: -> varAssignment(left=$variableRef.stright=$expr.sttoken=$st.tokendesc=$text)
            {
                retval.st = templateLib.getInstanceOf("varAssignment",
              new STAttrMap().put("left", (variableRef84!=null?variableRef84.st:null)).put("right", (expr85!=null?expr85.st:null)).put("token", st.token).put("desc", input.getTokenStream().toString(
              input.getTreeAdaptor().getTokenStartIndex(retval.start),
              input.getTreeAdaptor().getTokenStopIndex(retval.start))));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "assignment"

    public static class variableRef_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "variableRef"
    // ttcn3tree.g:1005:1: variableRef returns [TType t] : ( ^( FIELD_ACCESS id1= id (id2= id )+ ) -> unmodified(text=st) | id -> unmodified(text=st));
    public final ttcn3tree.variableRef_return variableRef() throws RecognitionException {
        ttcn3tree.variableRef_return retval = new ttcn3tree.variableRef_return();
        retval.start = input.LT(1);

        ttcn3tree.id_return id1 = null;

        ttcn3tree.id_return id2 = null;

        ttcn3tree.id_return id86 = null;



        	String st="";

        try {
            // ttcn3tree.g:1009:3: ( ^( FIELD_ACCESS id1= id (id2= id )+ ) -> unmodified(text=st) | id -> unmodified(text=st))
            int alt42=2;
            int LA42_0 = input.LA(1);

            if ( (LA42_0==FIELD_ACCESS) ) {
                alt42=1;
            }
            else if ( (LA42_0==ID) ) {
                alt42=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 42, 0, input);

                throw nvae;
            }
            switch (alt42) {
                case 1 :
                    // ttcn3tree.g:1009:5: ^( FIELD_ACCESS id1= id (id2= id )+ )
                    {
                    match(input,FIELD_ACCESS,FOLLOW_FIELD_ACCESS_in_variableRef2938); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_id_in_variableRef2942);
                    id1=id();

                    state._fsp--;


                                        //for component field reference
                                        st=(id1!=null?id1.text:null);
                                        if(runsOnComp!=null && null!=(retval.t =getFieldOfComponent(moduleName,runsOnComp, (id1!=null?id1.token:null)))) {
                                        	st="self."+st;
                                        }/* else if(runsOnSystem!=null && null!=(retval.t =getFieldOfComponent(moduleName, runsOnSystem, (id1!=null?id1.token:null)))){
                                        	st="sys."+st;	//Cannot access system component's member fields
                                        }*/

                    		   if(retval.t==null) {
                    		 	    retval.t = getType(moduleName, (id1!=null?id1.token:null), TAttrib.VALUE, null); 
                    		               if(retval.t!=null) {
                    	                        if(retval.t.getType().getSubAttrib() != TSubAttribTYPE.RECORD) {
                    	                            logError((id1!=null?id1.token:null), "Expecting RECORD type but %s given", retval.t.getSubAttrib());
                    	                            retval.t = null;
                    	                        }
                    	                    }
                                        }
                                        
                    	      
                    // ttcn3tree.g:1030:8: (id2= id )+
                    int cnt41=0;
                    loop41:
                    do {
                        int alt41=2;
                        int LA41_0 = input.LA(1);

                        if ( (LA41_0==ID) ) {
                            alt41=1;
                        }


                        switch (alt41) {
                    	case 1 :
                    	    // ttcn3tree.g:1030:10: id2= id
                    	    {
                    	    pushFollow(FOLLOW_id_in_variableRef2961);
                    	    id2=id();

                    	    state._fsp--;


                    	                    if(retval.t!=null) {
                    	                        retval.t = retval.t.getType().getSubTableItem((id2!=null?id2.text:null));
                    	                        if(retval.t==null) {
                    	                            logError((id2!=null?id2.token:null), "%s have no field \"%s\"", (id1!=null?id1.text:null), (id2!=null?id2.text:null));
                    	                        }
                    	                    }

                    	                    //for component field reference
                    	                    st=st+"."+(id2!=null?id2.text:null);
                    	                  

                    	    }
                    	    break;

                    	default :
                    	    if ( cnt41 >= 1 ) break loop41;
                                EarlyExitException eee =
                                    new EarlyExitException(41, input);
                                throw eee;
                        }
                        cnt41++;
                    } while (true);


                    match(input, Token.UP, null); 


                    // TEMPLATE REWRITE
                    // 1044:6: -> unmodified(text=st)
                    {
                        retval.st = templateLib.getInstanceOf("unmodified",
                      new STAttrMap().put("text", st));
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:1046:6: id
                    {
                    pushFollow(FOLLOW_id_in_variableRef3017);
                    id86=id();

                    state._fsp--;


                    	    	    st=(id86!=null?id86.text:null);
                                        if(runsOnComp!=null && null!=(retval.t =getFieldOfComponent(moduleName, runsOnComp, (id86!=null?id86.token:null)))) {
                                        	st="self."+st;
                                        }/* else if(runsOnSystem!=null && null!=(retval.t =getFieldOfComponent(moduleName, runsOnSystem, (id86!=null?id86.token:null)))){
                                        	st="sys."+st;	//same as above
                                        }*/
                    		    if(retval.t==null) 
                    		    	retval.t = getType(moduleName, (id86!=null?id86.token:null), TAttrib.VALUE, null);
                    	    


                    // TEMPLATE REWRITE
                    // 1057:6: -> unmodified(text=st)
                    {
                        retval.st = templateLib.getInstanceOf("unmodified",
                      new STAttrMap().put("text", st));
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "variableRef"

    public static class constExpr_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "constExpr"
    // ttcn3tree.g:1064:1: constExpr returns [TType t] : expr -> {$expr.st};
    public final ttcn3tree.constExpr_return constExpr() throws RecognitionException {
        ttcn3tree.constExpr_return retval = new ttcn3tree.constExpr_return();
        retval.start = input.LT(1);

        ttcn3tree.expr_return expr87 = null;


        try {
            // ttcn3tree.g:1065:3: ( expr -> {$expr.st})
            // ttcn3tree.g:1065:5: expr
            {
            pushFollow(FOLLOW_expr_in_constExpr3058);
            expr87=expr();

            state._fsp--;

              retval.t = (expr87!=null?expr87.t:null);
            	                if((expr87!=null?expr87.t:null)!=null) {
            	                  if((expr87!=null?expr87.t:null).getSubAttrib() != TSubAttribVALUE.CONST) {
            	                    logError((expr87!=null?expr87.t:null).getToken(), "Expecting const expression but %s(%s)", 
            	                        (expr87!=null?expr87.t:null).getSubAttrib(), (expr87!=null?(input.getTokenStream().toString(
              input.getTreeAdaptor().getTokenStartIndex(expr87.start),
              input.getTreeAdaptor().getTokenStopIndex(expr87.start))):null));
            	                    retval.t = null;
            	                }
            	              }
            	            


            // TEMPLATE REWRITE
            // 1074:5: -> {$expr.st}
            {
                retval.st = (expr87!=null?expr87.st:null);
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "constExpr"

    public static class boolExpr_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "boolExpr"
    // ttcn3tree.g:1077:1: boolExpr returns [TType t] : expr -> {$expr.st};
    public final ttcn3tree.boolExpr_return boolExpr() throws RecognitionException {
        ttcn3tree.boolExpr_return retval = new ttcn3tree.boolExpr_return();
        retval.start = input.LT(1);

        ttcn3tree.expr_return expr88 = null;


        try {
            // ttcn3tree.g:1078:3: ( expr -> {$expr.st})
            // ttcn3tree.g:1078:5: expr
            {
            pushFollow(FOLLOW_expr_in_boolExpr3089);
            expr88=expr();

            state._fsp--;

             retval.t = (expr88!=null?expr88.t:null);
            	              if((expr88!=null?expr88.t:null)!=null) {
            	                if((expr88!=null?expr88.t:null).getType().getSubAttrib() != TSubAttribTYPE.BOOLEAN) {
            	                    logError((expr88!=null?expr88.t:null).getToken(), "Expecting boolean expression but %s", 
            	                        (expr88!=null?expr88.t:null).getType().getSubAttrib());
            	                    retval.t = null;
            	                }
            	              }
            	            


            // TEMPLATE REWRITE
            // 1087:5: -> {$expr.st}
            {
                retval.st = (expr88!=null?expr88.st:null);
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "boolExpr"

    public static class expr_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "expr"
    // ttcn3tree.g:1091:1: expr returns [TType t] : ( ^(op= '==' e1= expr e2= expr ) -> equalOp(left=$e1.stright=$e2.st) | ^(op= '!=' e1= expr e2= expr ) -> notEqualOp(left=$e1.stright=$e2.st) | ^(op= '<' e1= expr e2= expr ) -> lessOp(left=$e1.stright=$e2.st) | ^(op= '<=' e1= expr e2= expr ) -> lessEqualOp(left=$e1.stright=$e2.st) | ^(op= '>' e1= expr e2= expr ) -> greaterOp(left=$e1.stright=$e2.st) | ^(op= '>=' e1= expr e2= expr ) -> greaterEqualOp(left=$e1.stright=$e2.st) | ^(op= '+' e1= expr e2= expr ) -> addOp(left=$e1.stright=$e2.st) | ^(op= '-' e1= expr e2= expr ) -> subOp(left=$e1.stright=$e2.st) | ^(op= '&' e1= expr e2= expr ) -> stringOp(left=$e1.stright=$e2.st) | ^(op= '*' e1= expr e2= expr ) -> mulOp(left=$e1.stright=$e2.st) | ^(op= '/' e1= expr e2= expr ) -> divOp(left=$e1.stright=$e2.st) | ^(op= 'mod' e1= expr e2= expr ) -> modOp(left=$e1.stright=$e2.st) | ^( UNARY_EXPR op= '-' e1= expr ) -> unarySubOp(left=$e1.st) | ^( UNARY_EXPR op= '+' e1= expr ) -> unaryAddOp(left=$e1.st) | value -> {$value.st} | opCall -> {$opCall.st});
    public final ttcn3tree.expr_return expr() throws RecognitionException {
        ttcn3tree.expr_return retval = new ttcn3tree.expr_return();
        retval.start = input.LT(1);

        CommonTree op=null;
        ttcn3tree.expr_return e1 = null;

        ttcn3tree.expr_return e2 = null;

        ttcn3tree.value_return value89 = null;

        ttcn3tree.opCall_return opCall90 = null;


        try {
            // ttcn3tree.g:1092:3: ( ^(op= '==' e1= expr e2= expr ) -> equalOp(left=$e1.stright=$e2.st) | ^(op= '!=' e1= expr e2= expr ) -> notEqualOp(left=$e1.stright=$e2.st) | ^(op= '<' e1= expr e2= expr ) -> lessOp(left=$e1.stright=$e2.st) | ^(op= '<=' e1= expr e2= expr ) -> lessEqualOp(left=$e1.stright=$e2.st) | ^(op= '>' e1= expr e2= expr ) -> greaterOp(left=$e1.stright=$e2.st) | ^(op= '>=' e1= expr e2= expr ) -> greaterEqualOp(left=$e1.stright=$e2.st) | ^(op= '+' e1= expr e2= expr ) -> addOp(left=$e1.stright=$e2.st) | ^(op= '-' e1= expr e2= expr ) -> subOp(left=$e1.stright=$e2.st) | ^(op= '&' e1= expr e2= expr ) -> stringOp(left=$e1.stright=$e2.st) | ^(op= '*' e1= expr e2= expr ) -> mulOp(left=$e1.stright=$e2.st) | ^(op= '/' e1= expr e2= expr ) -> divOp(left=$e1.stright=$e2.st) | ^(op= 'mod' e1= expr e2= expr ) -> modOp(left=$e1.stright=$e2.st) | ^( UNARY_EXPR op= '-' e1= expr ) -> unarySubOp(left=$e1.st) | ^( UNARY_EXPR op= '+' e1= expr ) -> unaryAddOp(left=$e1.st) | value -> {$value.st} | opCall -> {$opCall.st})
            int alt43=16;
            alt43 = dfa43.predict(input);
            switch (alt43) {
                case 1 :
                    // ttcn3tree.g:1092:5: ^(op= '==' e1= expr e2= expr )
                    {
                    op=(CommonTree)match(input,61,FOLLOW_61_in_expr3123); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expr_in_expr3127);
                    e1=expr();

                    state._fsp--;

                    pushFollow(FOLLOW_expr_in_expr3131);
                    e2=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2Bool(op.getToken(), (e1!=null?e1.t:null), (e2!=null?e2.t:null)); 


                    // TEMPLATE REWRITE
                    // 1093:6: -> equalOp(left=$e1.stright=$e2.st)
                    {
                        retval.st = templateLib.getInstanceOf("equalOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)).put("right", (e2!=null?e2.st:null)));
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:1094:5: ^(op= '!=' e1= expr e2= expr )
                    {
                    op=(CommonTree)match(input,62,FOLLOW_62_in_expr3163); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expr_in_expr3167);
                    e1=expr();

                    state._fsp--;

                    pushFollow(FOLLOW_expr_in_expr3171);
                    e2=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2Bool(op.getToken(), (e1!=null?e1.t:null), (e2!=null?e2.t:null)); 


                    // TEMPLATE REWRITE
                    // 1095:6: -> notEqualOp(left=$e1.stright=$e2.st)
                    {
                        retval.st = templateLib.getInstanceOf("notEqualOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)).put("right", (e2!=null?e2.st:null)));
                    }


                    }
                    break;
                case 3 :
                    // ttcn3tree.g:1096:5: ^(op= '<' e1= expr e2= expr )
                    {
                    op=(CommonTree)match(input,63,FOLLOW_63_in_expr3203); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expr_in_expr3207);
                    e1=expr();

                    state._fsp--;

                    pushFollow(FOLLOW_expr_in_expr3211);
                    e2=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2Bool(op.getToken(), (e1!=null?e1.t:null), (e2!=null?e2.t:null), TSubAttribTYPE.INTEGER/*, TSubAttribTYPE.FLOAT*/ ); 


                    // TEMPLATE REWRITE
                    // 1097:6: -> lessOp(left=$e1.stright=$e2.st)
                    {
                        retval.st = templateLib.getInstanceOf("lessOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)).put("right", (e2!=null?e2.st:null)));
                    }


                    }
                    break;
                case 4 :
                    // ttcn3tree.g:1098:5: ^(op= '<=' e1= expr e2= expr )
                    {
                    op=(CommonTree)match(input,64,FOLLOW_64_in_expr3243); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expr_in_expr3247);
                    e1=expr();

                    state._fsp--;

                    pushFollow(FOLLOW_expr_in_expr3251);
                    e2=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2Bool(op.getToken(), (e1!=null?e1.t:null), (e2!=null?e2.t:null), TSubAttribTYPE.INTEGER); 


                    // TEMPLATE REWRITE
                    // 1099:6: -> lessEqualOp(left=$e1.stright=$e2.st)
                    {
                        retval.st = templateLib.getInstanceOf("lessEqualOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)).put("right", (e2!=null?e2.st:null)));
                    }


                    }
                    break;
                case 5 :
                    // ttcn3tree.g:1100:5: ^(op= '>' e1= expr e2= expr )
                    {
                    op=(CommonTree)match(input,65,FOLLOW_65_in_expr3283); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expr_in_expr3287);
                    e1=expr();

                    state._fsp--;

                    pushFollow(FOLLOW_expr_in_expr3291);
                    e2=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2Bool(op.getToken(), (e1!=null?e1.t:null), (e2!=null?e2.t:null), TSubAttribTYPE.INTEGER); 


                    // TEMPLATE REWRITE
                    // 1101:6: -> greaterOp(left=$e1.stright=$e2.st)
                    {
                        retval.st = templateLib.getInstanceOf("greaterOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)).put("right", (e2!=null?e2.st:null)));
                    }


                    }
                    break;
                case 6 :
                    // ttcn3tree.g:1102:5: ^(op= '>=' e1= expr e2= expr )
                    {
                    op=(CommonTree)match(input,66,FOLLOW_66_in_expr3323); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expr_in_expr3327);
                    e1=expr();

                    state._fsp--;

                    pushFollow(FOLLOW_expr_in_expr3331);
                    e2=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2Bool(op.getToken(), (e1!=null?e1.t:null), (e2!=null?e2.t:null), TSubAttribTYPE.INTEGER); 


                    // TEMPLATE REWRITE
                    // 1103:6: -> greaterEqualOp(left=$e1.stright=$e2.st)
                    {
                        retval.st = templateLib.getInstanceOf("greaterEqualOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)).put("right", (e2!=null?e2.st:null)));
                    }


                    }
                    break;
                case 7 :
                    // ttcn3tree.g:1104:5: ^(op= '+' e1= expr e2= expr )
                    {
                    op=(CommonTree)match(input,67,FOLLOW_67_in_expr3363); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expr_in_expr3367);
                    e1=expr();

                    state._fsp--;

                    pushFollow(FOLLOW_expr_in_expr3371);
                    e2=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2(op.getToken(), (e1!=null?e1.t:null), (e2!=null?e2.t:null), TSubAttribTYPE.INTEGER); 


                    // TEMPLATE REWRITE
                    // 1105:6: -> addOp(left=$e1.stright=$e2.st)
                    {
                        retval.st = templateLib.getInstanceOf("addOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)).put("right", (e2!=null?e2.st:null)));
                    }


                    }
                    break;
                case 8 :
                    // ttcn3tree.g:1106:5: ^(op= '-' e1= expr e2= expr )
                    {
                    op=(CommonTree)match(input,68,FOLLOW_68_in_expr3403); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expr_in_expr3407);
                    e1=expr();

                    state._fsp--;

                    pushFollow(FOLLOW_expr_in_expr3411);
                    e2=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2(op.getToken(), (e1!=null?e1.t:null), (e2!=null?e2.t:null), TSubAttribTYPE.INTEGER); 


                    // TEMPLATE REWRITE
                    // 1107:6: -> subOp(left=$e1.stright=$e2.st)
                    {
                        retval.st = templateLib.getInstanceOf("subOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)).put("right", (e2!=null?e2.st:null)));
                    }


                    }
                    break;
                case 9 :
                    // ttcn3tree.g:1108:5: ^(op= '&' e1= expr e2= expr )
                    {
                    op=(CommonTree)match(input,69,FOLLOW_69_in_expr3443); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expr_in_expr3447);
                    e1=expr();

                    state._fsp--;

                    pushFollow(FOLLOW_expr_in_expr3451);
                    e2=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2(op.getToken(), (e1!=null?e1.t:null), (e2!=null?e2.t:null), TSubAttribTYPE.CHARSTRING); 


                    // TEMPLATE REWRITE
                    // 1109:6: -> stringOp(left=$e1.stright=$e2.st)
                    {
                        retval.st = templateLib.getInstanceOf("stringOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)).put("right", (e2!=null?e2.st:null)));
                    }


                    }
                    break;
                case 10 :
                    // ttcn3tree.g:1110:5: ^(op= '*' e1= expr e2= expr )
                    {
                    op=(CommonTree)match(input,70,FOLLOW_70_in_expr3483); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expr_in_expr3487);
                    e1=expr();

                    state._fsp--;

                    pushFollow(FOLLOW_expr_in_expr3491);
                    e2=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2(op.getToken(), (e1!=null?e1.t:null), (e2!=null?e2.t:null), TSubAttribTYPE.INTEGER); 


                    // TEMPLATE REWRITE
                    // 1111:6: -> mulOp(left=$e1.stright=$e2.st)
                    {
                        retval.st = templateLib.getInstanceOf("mulOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)).put("right", (e2!=null?e2.st:null)));
                    }


                    }
                    break;
                case 11 :
                    // ttcn3tree.g:1112:5: ^(op= '/' e1= expr e2= expr )
                    {
                    op=(CommonTree)match(input,71,FOLLOW_71_in_expr3523); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expr_in_expr3527);
                    e1=expr();

                    state._fsp--;

                    pushFollow(FOLLOW_expr_in_expr3531);
                    e2=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2(op.getToken(), (e1!=null?e1.t:null), (e2!=null?e2.t:null), TSubAttribTYPE.INTEGER); 


                    // TEMPLATE REWRITE
                    // 1113:6: -> divOp(left=$e1.stright=$e2.st)
                    {
                        retval.st = templateLib.getInstanceOf("divOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)).put("right", (e2!=null?e2.st:null)));
                    }


                    }
                    break;
                case 12 :
                    // ttcn3tree.g:1114:5: ^(op= 'mod' e1= expr e2= expr )
                    {
                    op=(CommonTree)match(input,72,FOLLOW_72_in_expr3563); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expr_in_expr3567);
                    e1=expr();

                    state._fsp--;

                    pushFollow(FOLLOW_expr_in_expr3571);
                    e2=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2(op.getToken(), (e1!=null?e1.t:null), (e2!=null?e2.t:null), TSubAttribTYPE.INTEGER); 


                    // TEMPLATE REWRITE
                    // 1115:6: -> modOp(left=$e1.stright=$e2.st)
                    {
                        retval.st = templateLib.getInstanceOf("modOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)).put("right", (e2!=null?e2.st:null)));
                    }


                    }
                    break;
                case 13 :
                    // ttcn3tree.g:1117:5: ^( UNARY_EXPR op= '-' e1= expr )
                    {
                    match(input,UNARY_EXPR,FOLLOW_UNARY_EXPR_in_expr3604); 

                    match(input, Token.DOWN, null); 
                    op=(CommonTree)match(input,68,FOLLOW_68_in_expr3608); 
                    pushFollow(FOLLOW_expr_in_expr3612);
                    e1=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2(op.getToken(), (e1!=null?e1.t:null), null, TSubAttribTYPE.INTEGER); 


                    // TEMPLATE REWRITE
                    // 1118:6: -> unarySubOp(left=$e1.st)
                    {
                        retval.st = templateLib.getInstanceOf("unarySubOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)));
                    }


                    }
                    break;
                case 14 :
                    // ttcn3tree.g:1119:5: ^( UNARY_EXPR op= '+' e1= expr )
                    {
                    match(input,UNARY_EXPR,FOLLOW_UNARY_EXPR_in_expr3638); 

                    match(input, Token.DOWN, null); 
                    op=(CommonTree)match(input,67,FOLLOW_67_in_expr3642); 
                    pushFollow(FOLLOW_expr_in_expr3646);
                    e1=expr();

                    state._fsp--;


                    match(input, Token.UP, null); 
                     retval.t = doE1E2(op.getToken(), (e1!=null?e1.t:null), null, TSubAttribTYPE.INTEGER); 


                    // TEMPLATE REWRITE
                    // 1120:6: -> unaryAddOp(left=$e1.st)
                    {
                        retval.st = templateLib.getInstanceOf("unaryAddOp",
                      new STAttrMap().put("left", (e1!=null?e1.st:null)));
                    }


                    }
                    break;
                case 15 :
                    // ttcn3tree.g:1122:5: value
                    {
                    pushFollow(FOLLOW_value_in_expr3671);
                    value89=value();

                    state._fsp--;

                    retval.t = (value89!=null?value89.t:null);


                    // TEMPLATE REWRITE
                    // 1122:49: -> {$value.st}
                    {
                        retval.st = (value89!=null?value89.st:null);
                    }


                    }
                    break;
                case 16 :
                    // ttcn3tree.g:1123:5: opCall
                    {
                    pushFollow(FOLLOW_opCall_in_expr3704);
                    opCall90=opCall();

                    state._fsp--;

                    retval.t =(opCall90!=null?opCall90.t:null);


                    // TEMPLATE REWRITE
                    // 1123:36: -> {$opCall.st}
                    {
                        retval.st = (opCall90!=null?opCall90.st:null);
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "expr"

    public static class value_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "value"
    // ttcn3tree.g:1126:1: value returns [TType t] : ( INT -> integerConst(value=$INT.text) | Cstring -> charstringConst(value=$Cstring.text) | (bv= 'true' | bv= 'false' ) -> booleanConst(value=$bv.text) | variableRef -> varRef(id=$variableRef.st) | functionInstance -> {$functionInstance.st});
    public final ttcn3tree.value_return value() throws RecognitionException {
        ttcn3tree.value_return retval = new ttcn3tree.value_return();
        retval.start = input.LT(1);

        CommonTree bv=null;
        CommonTree INT91=null;
        CommonTree Cstring92=null;
        ttcn3tree.variableRef_return variableRef93 = null;

        ttcn3tree.functionInstance_return functionInstance94 = null;


        try {
            // ttcn3tree.g:1127:3: ( INT -> integerConst(value=$INT.text) | Cstring -> charstringConst(value=$Cstring.text) | (bv= 'true' | bv= 'false' ) -> booleanConst(value=$bv.text) | variableRef -> varRef(id=$variableRef.st) | functionInstance -> {$functionInstance.st})
            int alt45=5;
            switch ( input.LA(1) ) {
            case INT:
                {
                alt45=1;
                }
                break;
            case Cstring:
                {
                alt45=2;
                }
                break;
            case 73:
            case 74:
                {
                alt45=3;
                }
                break;
            case FIELD_ACCESS:
            case ID:
                {
                alt45=4;
                }
                break;
            case FUNC_CALL:
                {
                alt45=5;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 45, 0, input);

                throw nvae;
            }

            switch (alt45) {
                case 1 :
                    // ttcn3tree.g:1127:5: INT
                    {
                    INT91=(CommonTree)match(input,INT,FOLLOW_INT_in_value3734); 
                    retval.t =newValue(INT91.getToken(), TSubAttribVALUE.CONST, getPredefinedType("integer"));


                    // TEMPLATE REWRITE
                    // 1128:6: -> integerConst(value=$INT.text)
                    {
                        retval.st = templateLib.getInstanceOf("integerConst",
                      new STAttrMap().put("value", (INT91!=null?INT91.getText():null)));
                    }


                    }
                    break;
                case 2 :
                    // ttcn3tree.g:1129:5: Cstring
                    {
                    Cstring92=(CommonTree)match(input,Cstring,FOLLOW_Cstring_in_value3768); 
                    retval.t =newValue(Cstring92.getToken(), TSubAttribVALUE.CONST, getPredefinedType("charstring"));


                    // TEMPLATE REWRITE
                    // 1130:6: -> charstringConst(value=$Cstring.text)
                    {
                        retval.st = templateLib.getInstanceOf("charstringConst",
                      new STAttrMap().put("value", (Cstring92!=null?Cstring92.getText():null)));
                    }


                    }
                    break;
                case 3 :
                    // ttcn3tree.g:1131:5: (bv= 'true' | bv= 'false' )
                    {
                    // ttcn3tree.g:1131:5: (bv= 'true' | bv= 'false' )
                    int alt44=2;
                    int LA44_0 = input.LA(1);

                    if ( (LA44_0==73) ) {
                        alt44=1;
                    }
                    else if ( (LA44_0==74) ) {
                        alt44=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 44, 0, input);

                        throw nvae;
                    }
                    switch (alt44) {
                        case 1 :
                            // ttcn3tree.g:1131:6: bv= 'true'
                            {
                            bv=(CommonTree)match(input,73,FOLLOW_73_in_value3801); 

                            }
                            break;
                        case 2 :
                            // ttcn3tree.g:1131:18: bv= 'false'
                            {
                            bv=(CommonTree)match(input,74,FOLLOW_74_in_value3807); 

                            }
                            break;

                    }

                    retval.t =newValue(bv.getToken(), TSubAttribVALUE.CONST, getPredefinedType("boolean"));


                    // TEMPLATE REWRITE
                    // 1132:6: -> booleanConst(value=$bv.text)
                    {
                        retval.st = templateLib.getInstanceOf("booleanConst",
                      new STAttrMap().put("value", (bv!=null?bv.getText():null)));
                    }


                    }
                    break;
                case 4 :
                    // ttcn3tree.g:1133:5: variableRef
                    {
                    pushFollow(FOLLOW_variableRef_in_value3833);
                    variableRef93=variableRef();

                    state._fsp--;

                    retval.t = (variableRef93!=null?variableRef93.t:null);


                    // TEMPLATE REWRITE
                    // 1134:6: -> varRef(id=$variableRef.st)
                    {
                        retval.st = templateLib.getInstanceOf("varRef",
                      new STAttrMap().put("id", (variableRef93!=null?variableRef93.st:null)));
                    }


                    }
                    break;
                case 5 :
                    // ttcn3tree.g:1135:5: functionInstance
                    {
                    pushFollow(FOLLOW_functionInstance_in_value3863);
                    functionInstance94=functionInstance();

                    state._fsp--;

                    retval.t = (functionInstance94!=null?functionInstance94.t:null);


                    // TEMPLATE REWRITE
                    // 1136:6: -> {$functionInstance.st}
                    {
                        retval.st = (functionInstance94!=null?functionInstance94.st:null);
                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "value"

    public static class opCall_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "opCall"
    // ttcn3tree.g:1139:1: opCall returns [TType t] : configurationOps -> {$configurationOps.st};
    public final ttcn3tree.opCall_return opCall() throws RecognitionException {
        ttcn3tree.opCall_return retval = new ttcn3tree.opCall_return();
        retval.start = input.LT(1);

        ttcn3tree.configurationOps_return configurationOps95 = null;


        try {
            // ttcn3tree.g:1140:2: ( configurationOps -> {$configurationOps.st})
            // ttcn3tree.g:1140:4: configurationOps
            {
            pushFollow(FOLLOW_configurationOps_in_opCall3901);
            configurationOps95=configurationOps();

            state._fsp--;

            retval.t =(configurationOps95!=null?configurationOps95.t:null);


            // TEMPLATE REWRITE
            // 1140:47: -> {$configurationOps.st}
            {
                retval.st = (configurationOps95!=null?configurationOps95.st:null);
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "opCall"

    public static class configurationOps_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "configurationOps"
    // ttcn3tree.g:1142:1: configurationOps returns [TType t] : createOp -> {$createOp.st};
    public final ttcn3tree.configurationOps_return configurationOps() throws RecognitionException {
        ttcn3tree.configurationOps_return retval = new ttcn3tree.configurationOps_return();
        retval.start = input.LT(1);

        ttcn3tree.createOp_return createOp96 = null;


        try {
            // ttcn3tree.g:1143:2: ( createOp -> {$createOp.st})
            // ttcn3tree.g:1143:4: createOp
            {
            pushFollow(FOLLOW_createOp_in_configurationOps3920);
            createOp96=createOp();

            state._fsp--;

            retval.t =(createOp96!=null?createOp96.t:null);


            // TEMPLATE REWRITE
            // 1143:31: -> {$createOp.st}
            {
                retval.st = (createOp96!=null?createOp96.st:null);
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "configurationOps"

    public static class createOp_return extends TreeRuleReturnScope {
        public TType t;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "createOp"
    // ttcn3tree.g:1148:1: createOp returns [TType t] : ^( 'create' componentType ) -> createComponentOp(componentName=$componentType.textmoduleName=moduleName);
    public final ttcn3tree.createOp_return createOp() throws RecognitionException {
        ttcn3tree.createOp_return retval = new ttcn3tree.createOp_return();
        retval.start = input.LT(1);

        ttcn3tree.componentType_return componentType97 = null;


        try {
            // ttcn3tree.g:1149:2: ( ^( 'create' componentType ) -> createComponentOp(componentName=$componentType.textmoduleName=moduleName))
            // ttcn3tree.g:1149:4: ^( 'create' componentType )
            {
            match(input,75,FOLLOW_75_in_createOp3943); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_componentType_in_createOp3945);
            componentType97=componentType();

            state._fsp--;


            match(input, Token.UP, null); 
             
            			retval.t = getComponent(moduleName, (componentType97!=null?componentType97.text:null), (componentType97!=null?componentType97.token:null));
            			if(retval.t!=null){
            				retval.t = newValue((componentType97!=null?componentType97.token:null), TSubAttribVALUE.VAR, retval.t);
            			}
            		


            // TEMPLATE REWRITE
            // 1156:3: -> createComponentOp(componentName=$componentType.textmoduleName=moduleName)
            {
                retval.st = templateLib.getInstanceOf("createComponentOp",
              new STAttrMap().put("componentName", (componentType97!=null?componentType97.text:null)).put("moduleName", moduleName));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "createOp"

    public static class componentType_return extends TreeRuleReturnScope {
        public Token token;
        public String text;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "componentType"
    // ttcn3tree.g:1159:1: componentType returns [Token token, String text] : id ;
    public final ttcn3tree.componentType_return componentType() throws RecognitionException {
        ttcn3tree.componentType_return retval = new ttcn3tree.componentType_return();
        retval.start = input.LT(1);

        ttcn3tree.id_return id98 = null;


        try {
            // ttcn3tree.g:1160:2: ( id )
            // ttcn3tree.g:1160:4: id
            {
            pushFollow(FOLLOW_id_in_componentType3979);
            id98=id();

            state._fsp--;

            retval.token = (id98!=null?id98.token:null); retval.text = (id98!=null?id98.text:null);

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "componentType"

    public static class id_return extends TreeRuleReturnScope {
        public Token token;
        public String text;
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "id"
    // ttcn3tree.g:1165:1: id returns [Token token, String text] : ID ;
    public final ttcn3tree.id_return id() throws RecognitionException {
        ttcn3tree.id_return retval = new ttcn3tree.id_return();
        retval.start = input.LT(1);

        CommonTree ID99=null;

        try {
            // ttcn3tree.g:1166:5: ( ID )
            // ttcn3tree.g:1166:7: ID
            {
            ID99=(CommonTree)match(input,ID,FOLLOW_ID_in_id4000); 
            retval.token =ID99.token; 
                    retval.text =(ID99!=null?ID99.getText():null);//+"_"; 
                    retval.token.setText((ID99!=null?ID99.getText():null));//+"_");
                    

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "id"

    // Delegated rules


    protected DFA19 dfa19 = new DFA19(this);
    protected DFA20 dfa20 = new DFA20(this);
    protected DFA21 dfa21 = new DFA21(this);
    protected DFA28 dfa28 = new DFA28(this);
    protected DFA39 dfa39 = new DFA39(this);
    protected DFA40 dfa40 = new DFA40(this);
    protected DFA43 dfa43 = new DFA43(this);
    static final String DFA19_eotS =
        "\20\uffff";
    static final String DFA19_eofS =
        "\20\uffff";
    static final String DFA19_minS =
        "\1\3\17\uffff";
    static final String DFA19_maxS =
        "\1\74\17\uffff";
    static final String DFA19_acceptS =
        "\1\uffff\1\1\15\uffff\1\2";
    static final String DFA19_specialS =
        "\20\uffff}>";
    static final String[] DFA19_transitionS = {
            "\1\17\1\1\37\uffff\2\1\3\uffff\1\1\4\uffff\2\1\3\uffff\3\1"+
            "\1\uffff\4\1\1\uffff\1\1",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA19_eot = DFA.unpackEncodedString(DFA19_eotS);
    static final short[] DFA19_eof = DFA.unpackEncodedString(DFA19_eofS);
    static final char[] DFA19_min = DFA.unpackEncodedStringToUnsignedChars(DFA19_minS);
    static final char[] DFA19_max = DFA.unpackEncodedStringToUnsignedChars(DFA19_maxS);
    static final short[] DFA19_accept = DFA.unpackEncodedString(DFA19_acceptS);
    static final short[] DFA19_special = DFA.unpackEncodedString(DFA19_specialS);
    static final short[][] DFA19_transition;

    static {
        int numStates = DFA19_transitionS.length;
        DFA19_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA19_transition[i] = DFA.unpackEncodedString(DFA19_transitionS[i]);
        }
    }

    class DFA19 extends DFA {

        public DFA19(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 19;
            this.eot = DFA19_eot;
            this.eof = DFA19_eof;
            this.min = DFA19_min;
            this.max = DFA19_max;
            this.accept = DFA19_accept;
            this.special = DFA19_special;
            this.transition = DFA19_transition;
        }
        public String getDescription() {
            return "619:14: ( functionStatementOrDefList )?";
        }
    }
    static final String DFA20_eotS =
        "\20\uffff";
    static final String DFA20_eofS =
        "\20\uffff";
    static final String DFA20_minS =
        "\1\3\17\uffff";
    static final String DFA20_maxS =
        "\1\74\17\uffff";
    static final String DFA20_acceptS =
        "\1\uffff\1\2\1\1\15\uffff";
    static final String DFA20_specialS =
        "\20\uffff}>";
    static final String[] DFA20_transitionS = {
            "\1\1\1\2\37\uffff\2\2\3\uffff\1\2\4\uffff\2\2\3\uffff\3\2\1"+
            "\uffff\4\2\1\uffff\1\2",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA20_eot = DFA.unpackEncodedString(DFA20_eotS);
    static final short[] DFA20_eof = DFA.unpackEncodedString(DFA20_eofS);
    static final char[] DFA20_min = DFA.unpackEncodedStringToUnsignedChars(DFA20_minS);
    static final char[] DFA20_max = DFA.unpackEncodedStringToUnsignedChars(DFA20_maxS);
    static final short[] DFA20_accept = DFA.unpackEncodedString(DFA20_acceptS);
    static final short[] DFA20_special = DFA.unpackEncodedString(DFA20_specialS);
    static final short[][] DFA20_transition;

    static {
        int numStates = DFA20_transitionS.length;
        DFA20_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA20_transition[i] = DFA.unpackEncodedString(DFA20_transitionS[i]);
        }
    }

    class DFA20 extends DFA {

        public DFA20(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 20;
            this.eot = DFA20_eot;
            this.eof = DFA20_eof;
            this.min = DFA20_min;
            this.max = DFA20_max;
            this.accept = DFA20_accept;
            this.special = DFA20_special;
            this.transition = DFA20_transition;
        }
        public String getDescription() {
            return "()+ loopback of 625:5: (locals+= functionStatementOrDef )+";
        }
    }
    static final String DFA21_eotS =
        "\17\uffff";
    static final String DFA21_eofS =
        "\17\uffff";
    static final String DFA21_minS =
        "\1\4\16\uffff";
    static final String DFA21_maxS =
        "\1\74\16\uffff";
    static final String DFA21_acceptS =
        "\1\uffff\1\1\1\uffff\1\2\13\uffff";
    static final String DFA21_specialS =
        "\17\uffff}>";
    static final String[] DFA21_transitionS = {
            "\1\3\37\uffff\1\1\1\3\3\uffff\1\3\4\uffff\1\1\1\3\3\uffff\3"+
            "\3\1\uffff\4\3\1\uffff\1\3",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA21_eot = DFA.unpackEncodedString(DFA21_eotS);
    static final short[] DFA21_eof = DFA.unpackEncodedString(DFA21_eofS);
    static final char[] DFA21_min = DFA.unpackEncodedStringToUnsignedChars(DFA21_minS);
    static final char[] DFA21_max = DFA.unpackEncodedStringToUnsignedChars(DFA21_maxS);
    static final short[] DFA21_accept = DFA.unpackEncodedString(DFA21_acceptS);
    static final short[] DFA21_special = DFA.unpackEncodedString(DFA21_specialS);
    static final short[][] DFA21_transition;

    static {
        int numStates = DFA21_transitionS.length;
        DFA21_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA21_transition[i] = DFA.unpackEncodedString(DFA21_transitionS[i]);
        }
    }

    class DFA21 extends DFA {

        public DFA21(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 21;
            this.eot = DFA21_eot;
            this.eof = DFA21_eof;
            this.min = DFA21_min;
            this.max = DFA21_max;
            this.accept = DFA21_accept;
            this.special = DFA21_special;
            this.transition = DFA21_transition;
        }
        public String getDescription() {
            return "628:1: functionStatementOrDef : ( functionLocalDef -> {$functionLocalDef.st} | functionStatement -> {$functionStatement.st});";
        }
    }
    static final String DFA28_eotS =
        "\15\uffff";
    static final String DFA28_eofS =
        "\15\uffff";
    static final String DFA28_minS =
        "\1\4\14\uffff";
    static final String DFA28_maxS =
        "\1\74\14\uffff";
    static final String DFA28_acceptS =
        "\1\uffff\1\1\3\uffff\1\2\2\uffff\1\3\4\uffff";
    static final String DFA28_specialS =
        "\15\uffff}>";
    static final String[] DFA28_transitionS = {
            "\1\5\40\uffff\1\1\3\uffff\1\5\5\uffff\1\10\3\uffff\3\10\1\uffff"+
            "\1\10\1\5\2\1\1\uffff\1\1",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA28_eot = DFA.unpackEncodedString(DFA28_eotS);
    static final short[] DFA28_eof = DFA.unpackEncodedString(DFA28_eofS);
    static final char[] DFA28_min = DFA.unpackEncodedStringToUnsignedChars(DFA28_minS);
    static final char[] DFA28_max = DFA.unpackEncodedStringToUnsignedChars(DFA28_maxS);
    static final short[] DFA28_accept = DFA.unpackEncodedString(DFA28_acceptS);
    static final short[] DFA28_special = DFA.unpackEncodedString(DFA28_specialS);
    static final short[][] DFA28_transition;

    static {
        int numStates = DFA28_transitionS.length;
        DFA28_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA28_transition[i] = DFA.unpackEncodedString(DFA28_transitionS[i]);
        }
    }

    class DFA28 extends DFA {

        public DFA28(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 28;
            this.eot = DFA28_eot;
            this.eof = DFA28_eof;
            this.min = DFA28_min;
            this.max = DFA28_max;
            this.accept = DFA28_accept;
            this.special = DFA28_special;
            this.transition = DFA28_transition;
        }
        public String getDescription() {
            return "727:1: functionStatement : ( basicStatements -> {$basicStatements.st} | behaviourStatements -> {$behaviourStatements.st} | configurationStatements -> {$configurationStatements.st});";
        }
    }
    static final String DFA39_eotS =
        "\27\uffff";
    static final String DFA39_eofS =
        "\27\uffff";
    static final String DFA39_minS =
        "\1\3\26\uffff";
    static final String DFA39_maxS =
        "\1\113\26\uffff";
    static final String DFA39_acceptS =
        "\1\uffff\1\2\1\1\24\uffff";
    static final String DFA39_specialS =
        "\27\uffff}>";
    static final String[] DFA39_transitionS = {
            "\1\1\1\2\1\uffff\1\2\3\uffff\1\2\5\uffff\3\2\52\uffff\17\2",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA39_eot = DFA.unpackEncodedString(DFA39_eotS);
    static final short[] DFA39_eof = DFA.unpackEncodedString(DFA39_eofS);
    static final char[] DFA39_min = DFA.unpackEncodedStringToUnsignedChars(DFA39_minS);
    static final char[] DFA39_max = DFA.unpackEncodedStringToUnsignedChars(DFA39_maxS);
    static final short[] DFA39_accept = DFA.unpackEncodedString(DFA39_acceptS);
    static final short[] DFA39_special = DFA.unpackEncodedString(DFA39_specialS);
    static final short[][] DFA39_transition;

    static {
        int numStates = DFA39_transitionS.length;
        DFA39_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA39_transition[i] = DFA.unpackEncodedString(DFA39_transitionS[i]);
        }
    }

    class DFA39 extends DFA {

        public DFA39(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 39;
            this.eot = DFA39_eot;
            this.eof = DFA39_eof;
            this.min = DFA39_min;
            this.max = DFA39_max;
            this.accept = DFA39_accept;
            this.special = DFA39_special;
            this.transition = DFA39_transition;
        }
        public String getDescription() {
            return "()+ loopback of 955:20: (a+= expr )+";
        }
    }
    static final String DFA40_eotS =
        "\27\uffff";
    static final String DFA40_eofS =
        "\27\uffff";
    static final String DFA40_minS =
        "\1\3\26\uffff";
    static final String DFA40_maxS =
        "\1\113\26\uffff";
    static final String DFA40_acceptS =
        "\1\uffff\1\1\24\uffff\1\2";
    static final String DFA40_specialS =
        "\27\uffff}>";
    static final String[] DFA40_transitionS = {
            "\1\26\1\1\1\uffff\1\1\3\uffff\1\1\5\uffff\3\1\52\uffff\17\1",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA40_eot = DFA.unpackEncodedString(DFA40_eotS);
    static final short[] DFA40_eof = DFA.unpackEncodedString(DFA40_eofS);
    static final char[] DFA40_min = DFA.unpackEncodedStringToUnsignedChars(DFA40_minS);
    static final char[] DFA40_max = DFA.unpackEncodedStringToUnsignedChars(DFA40_maxS);
    static final short[] DFA40_accept = DFA.unpackEncodedString(DFA40_acceptS);
    static final short[] DFA40_special = DFA.unpackEncodedString(DFA40_specialS);
    static final short[][] DFA40_transition;

    static {
        int numStates = DFA40_transitionS.length;
        DFA40_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA40_transition[i] = DFA.unpackEncodedString(DFA40_transitionS[i]);
        }
    }

    class DFA40 extends DFA {

        public DFA40(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 40;
            this.eot = DFA40_eot;
            this.eof = DFA40_eof;
            this.min = DFA40_min;
            this.max = DFA40_max;
            this.accept = DFA40_accept;
            this.special = DFA40_special;
            this.transition = DFA40_transition;
        }
        public String getDescription() {
            return "971:19: ( expr )?";
        }
    }
    static final String DFA43_eotS =
        "\31\uffff";
    static final String DFA43_eofS =
        "\31\uffff";
    static final String DFA43_minS =
        "\1\4\14\uffff\1\2\10\uffff\1\103\2\uffff";
    static final String DFA43_maxS =
        "\1\113\14\uffff\1\2\10\uffff\1\104\2\uffff";
    static final String DFA43_acceptS =
        "\1\uffff\1\1\1\2\1\3\1\4\1\5\1\6\1\7\1\10\1\11\1\12\1\13\1\14\1"+
        "\uffff\1\17\6\uffff\1\20\1\uffff\1\15\1\16";
    static final String DFA43_specialS =
        "\31\uffff}>";
    static final String[] DFA43_transitionS = {
            "\1\16\1\uffff\1\15\3\uffff\1\16\5\uffff\3\16\52\uffff\1\1\1"+
            "\2\1\3\1\4\1\5\1\6\1\7\1\10\1\11\1\12\1\13\1\14\2\16\1\25",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "\1\26",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "\1\30\1\27",
            "",
            ""
    };

    static final short[] DFA43_eot = DFA.unpackEncodedString(DFA43_eotS);
    static final short[] DFA43_eof = DFA.unpackEncodedString(DFA43_eofS);
    static final char[] DFA43_min = DFA.unpackEncodedStringToUnsignedChars(DFA43_minS);
    static final char[] DFA43_max = DFA.unpackEncodedStringToUnsignedChars(DFA43_maxS);
    static final short[] DFA43_accept = DFA.unpackEncodedString(DFA43_acceptS);
    static final short[] DFA43_special = DFA.unpackEncodedString(DFA43_specialS);
    static final short[][] DFA43_transition;

    static {
        int numStates = DFA43_transitionS.length;
        DFA43_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA43_transition[i] = DFA.unpackEncodedString(DFA43_transitionS[i]);
        }
    }

    class DFA43 extends DFA {

        public DFA43(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 43;
            this.eot = DFA43_eot;
            this.eof = DFA43_eof;
            this.min = DFA43_min;
            this.max = DFA43_max;
            this.accept = DFA43_accept;
            this.special = DFA43_special;
            this.transition = DFA43_transition;
        }
        public String getDescription() {
            return "1091:1: expr returns [TType t] : ( ^(op= '==' e1= expr e2= expr ) -> equalOp(left=$e1.stright=$e2.st) | ^(op= '!=' e1= expr e2= expr ) -> notEqualOp(left=$e1.stright=$e2.st) | ^(op= '<' e1= expr e2= expr ) -> lessOp(left=$e1.stright=$e2.st) | ^(op= '<=' e1= expr e2= expr ) -> lessEqualOp(left=$e1.stright=$e2.st) | ^(op= '>' e1= expr e2= expr ) -> greaterOp(left=$e1.stright=$e2.st) | ^(op= '>=' e1= expr e2= expr ) -> greaterEqualOp(left=$e1.stright=$e2.st) | ^(op= '+' e1= expr e2= expr ) -> addOp(left=$e1.stright=$e2.st) | ^(op= '-' e1= expr e2= expr ) -> subOp(left=$e1.stright=$e2.st) | ^(op= '&' e1= expr e2= expr ) -> stringOp(left=$e1.stright=$e2.st) | ^(op= '*' e1= expr e2= expr ) -> mulOp(left=$e1.stright=$e2.st) | ^(op= '/' e1= expr e2= expr ) -> divOp(left=$e1.stright=$e2.st) | ^(op= 'mod' e1= expr e2= expr ) -> modOp(left=$e1.stright=$e2.st) | ^( UNARY_EXPR op= '-' e1= expr ) -> unarySubOp(left=$e1.st) | ^( UNARY_EXPR op= '+' e1= expr ) -> unaryAddOp(left=$e1.st) | value -> {$value.st} | opCall -> {$opCall.st});";
        }
    }
 

    public static final BitSet FOLLOW_ttcn3Modules_in_ttcn3File72 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ttcn3Module_in_ttcn3Modules121 = new BitSet(new long[]{0x0000000000800002L});
    public static final BitSet FOLLOW_EOF_in_ttcn3Modules131 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_23_in_ttcn3Module157 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_ttcn3Module159 = new BitSet(new long[]{0x0000105026000008L});
    public static final BitSet FOLLOW_moduleDefinitionList_in_ttcn3Module173 = new BitSet(new long[]{0x0000000002000008L});
    public static final BitSet FOLLOW_moduleControlPart_in_ttcn3Module187 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_25_in_moduleControlPart356 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_statementBlock_in_moduleControlPart358 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_moduleDefinition_in_moduleDefinitionList409 = new BitSet(new long[]{0x0000105024000002L});
    public static final BitSet FOLLOW_typeDef_in_moduleDefinition437 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_constDef_in_moduleDefinition455 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_functionDef_in_moduleDefinition469 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_importDef_in_moduleDefinition480 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_testcaseDef_in_moduleDefinition490 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_26_in_importDef509 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_27_in_importDef511 = new BitSet(new long[]{0x0000000000040000L});
    public static final BitSet FOLLOW_id_in_importDef513 = new BitSet(new long[]{0x0000000010000000L});
    public static final BitSet FOLLOW_28_in_importDef515 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_29_in_typeDef555 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_typeDefBody_in_typeDef557 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_structuredTypeDef_in_typeDefBody578 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_subTypeDef_in_typeDefBody590 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_recordDef_in_structuredTypeDef610 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_componentDef_in_structuredTypeDef622 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_30_in_recordDef643 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_structDefBody_in_recordDef645 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_id_in_structDefBody698 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_structFieldDef_in_structDefBody700 = new BitSet(new long[]{0x0000000000040008L});
    public static final BitSet FOLLOW_id_in_structFieldDef722 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_typeName_in_structFieldDef724 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_id_in_subTypeDef742 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_typeName_in_subTypeDef744 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_32_in_componentDef799 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_componentDef801 = new BitSet(new long[]{0x0000401000000008L});
    public static final BitSet FOLLOW_componentDefList_in_componentDef803 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_componentElementDef_in_componentDefList852 = new BitSet(new long[]{0x0000401000000002L});
    public static final BitSet FOLLOW_varInstance_in_componentElementDef866 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_constDef_in_componentElementDef875 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_33_in_typeName899 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_34_in_typeName926 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_35_in_typeName950 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_id_in_typeName977 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_36_in_constDef1020 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_typeName_in_constDef1022 = new BitSet(new long[]{0x0000002000000000L});
    public static final BitSet FOLLOW_constInitial_in_constDef1028 = new BitSet(new long[]{0x0000002000000008L});
    public static final BitSet FOLLOW_37_in_constInitial1087 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_constInitial1089 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_constExpr_in_constInitial1091 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_38_in_functionDef1151 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_functionDef1153 = new BitSet(new long[]{0x0000020000000920L});
    public static final BitSet FOLLOW_functionFormalParList_in_functionDef1155 = new BitSet(new long[]{0x0000020000000920L});
    public static final BitSet FOLLOW_runsOnSpec_in_functionDef1159 = new BitSet(new long[]{0x0000020000000920L});
    public static final BitSet FOLLOW_returnType_in_functionDef1162 = new BitSet(new long[]{0x0000020000000920L});
    public static final BitSet FOLLOW_statementBlock_in_functionDef1182 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_41_in_returnType1268 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_typeName_in_returnType1270 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_RUNS_ON_in_runsOnSpec1294 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_componentType_in_runsOnSpec1296 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_FORMAL_ARGS_in_functionFormalParList1327 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_functionFormalPar_in_functionFormalParList1330 = new BitSet(new long[]{0x0000000000000208L});
    public static final BitSet FOLLOW_formalValuePar_in_functionFormalPar1364 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_FORMAL_VAR_in_formalValuePar1384 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_typeName_in_formalValuePar1386 = new BitSet(new long[]{0x0000000000040000L});
    public static final BitSet FOLLOW_id_in_formalValuePar1388 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_BLOCK_in_statementBlock1425 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_functionStatementOrDefList_in_statementBlock1429 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_functionStatementOrDef_in_functionStatementOrDefList1476 = new BitSet(new long[]{0x17B8C23000070412L,0x0000000000000600L});
    public static final BitSet FOLLOW_functionLocalDef_in_functionStatementOrDef1494 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_functionStatement_in_functionStatementOrDef1508 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_constDef_in_functionLocalDef1528 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_varInstance_in_functionLocalDef1542 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_44_in_testcaseDef1575 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_testcaseDef1577 = new BitSet(new long[]{0x0000008000000000L});
    public static final BitSet FOLLOW_39_in_testcaseDef1580 = new BitSet(new long[]{0x0000010000000100L});
    public static final BitSet FOLLOW_testcaseFormalParList_in_testcaseDef1582 = new BitSet(new long[]{0x0000010000000000L});
    public static final BitSet FOLLOW_40_in_testcaseDef1586 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_runsOnSpec_in_testcaseDef1588 = new BitSet(new long[]{0x0000220000000920L});
    public static final BitSet FOLLOW_systemSpec_in_testcaseDef1590 = new BitSet(new long[]{0x0000020000000920L});
    public static final BitSet FOLLOW_statementBlock_in_testcaseDef1600 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_45_in_systemSpec1658 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_systemSpec1660 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_FORMAL_ARGS_in_testcaseFormalParList1685 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_testcaseFormalPar_in_testcaseFormalParList1688 = new BitSet(new long[]{0x0000000000000208L});
    public static final BitSet FOLLOW_formalValuePar_in_testcaseFormalPar1710 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_46_in_varInstance1734 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_typeName_in_varInstance1736 = new BitSet(new long[]{0x0000002000040000L});
    public static final BitSet FOLLOW_var_in_varInstance1742 = new BitSet(new long[]{0x0000002000040008L});
    public static final BitSet FOLLOW_id_in_var1796 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_37_in_var1836 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_var1838 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_var1840 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_basicStatements_in_functionStatement1890 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_behaviourStatements_in_functionStatement1900 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_configurationStatements_in_functionStatement1910 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_assignment_in_basicStatements1925 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_loopConstruct_in_basicStatements1948 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_conditionalConstruct_in_basicStatements1959 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_logStatement_in_basicStatements1968 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_functionInstance_in_behaviourStatements1995 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_testcaseInstance_in_behaviourStatements2011 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_returnStatement_in_behaviourStatements2020 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_startTCStatement_in_configurationStatements2044 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_connectStatement_in_configurationStatements2087 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_disconnectStatement_in_configurationStatements2096 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_mapStatement_in_configurationStatements2105 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_unmapStatement_in_configurationStatements2115 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_47_in_connectStatement2131 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_singleConnectionSpec_in_connectStatement2133 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_51_in_disconnectStatement2149 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_singleOrMultiConnectionSpec_in_disconnectStatement2151 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_SINGLE_CONNECT_in_singleConnectionSpec2167 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_portRef_in_singleConnectionSpec2169 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_portRef_in_singleConnectionSpec2171 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_PORT_REF_in_portRef2183 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_componentRef_in_portRef2185 = new BitSet(new long[]{0x0000000000040000L});
    public static final BitSet FOLLOW_port_in_portRef2187 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_componentOrDefaultReference_in_componentRef2198 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_45_in_componentRef2204 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_49_in_componentRef2210 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_50_in_componentRef2216 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_portIdentifier_in_port2226 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_id_in_portIdentifier2236 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_singleConnectionSpec_in_singleOrMultiConnectionSpec2246 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_52_in_mapStatement2262 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_singleConnectionSpec_in_mapStatement2264 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_53_in_unmapStatement2281 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_singleOrMultiConnectionSpec_in_unmapStatement2284 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_55_in_startTCStatement2314 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_componentOrDefaultReference_in_startTCStatement2316 = new BitSet(new long[]{0x0000000000070410L,0x0000000000000600L});
    public static final BitSet FOLLOW_functionInstance_in_startTCStatement2320 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_variableRef_in_componentOrDefaultReference2341 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_56_in_testcaseInstance2370 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_testcaseInstance2372 = new BitSet(new long[]{0x0000000000000088L});
    public static final BitSet FOLLOW_testcaseActualParList_in_testcaseInstance2381 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_actualArgs_in_testcaseActualParList2447 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_57_in_loopConstruct2465 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_initExpr_in_loopConstruct2467 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_conditionExpr_in_loopConstruct2469 = new BitSet(new long[]{0x0000002000000000L});
    public static final BitSet FOLLOW_stepExpr_in_loopConstruct2471 = new BitSet(new long[]{0x0000020000000920L});
    public static final BitSet FOLLOW_statementBlock_in_loopConstruct2473 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_varInstance_in_initExpr2490 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_assignment_in_initExpr2497 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_boolExpr_in_conditionExpr2510 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_assignment_in_stepExpr2524 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_58_in_conditionalConstruct2540 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_boolExpr_in_conditionalConstruct2542 = new BitSet(new long[]{0x0000020000000920L});
    public static final BitSet FOLLOW_statementBlock_in_conditionalConstruct2544 = new BitSet(new long[]{0x0000020000000928L});
    public static final BitSet FOLLOW_statementBlock_in_conditionalConstruct2547 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_60_in_logStatement2567 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_actualArgs_in_logStatement2571 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_FUNC_CALL_in_functionInstance2625 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_functionInstance2627 = new BitSet(new long[]{0x0000000000000088L});
    public static final BitSet FOLLOW_actualArgs_in_functionInstance2654 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ACTUAL_ARGS_in_actualArgs2771 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_actualArgs2777 = new BitSet(new long[]{0xE000000000070458L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_41_in_returnStatement2812 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_returnStatement2816 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_37_in_assignment2874 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_variableRef_in_assignment2876 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_assignment2878 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_FIELD_ACCESS_in_variableRef2938 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_variableRef2942 = new BitSet(new long[]{0x0000000000040000L});
    public static final BitSet FOLLOW_id_in_variableRef2961 = new BitSet(new long[]{0x0000000000040008L});
    public static final BitSet FOLLOW_id_in_variableRef3017 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_expr_in_constExpr3058 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_expr_in_boolExpr3089 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_61_in_expr3123 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_expr3127 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3131 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_62_in_expr3163 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_expr3167 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3171 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_63_in_expr3203 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_expr3207 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3211 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_64_in_expr3243 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_expr3247 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3251 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_65_in_expr3283 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_expr3287 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3291 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_66_in_expr3323 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_expr3327 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3331 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_67_in_expr3363 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_expr3367 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3371 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_68_in_expr3403 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_expr3407 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3411 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_69_in_expr3443 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_expr3447 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3451 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_70_in_expr3483 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_expr3487 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3491 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_71_in_expr3523 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_expr3527 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3531 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_72_in_expr3563 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_expr3567 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3571 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_UNARY_EXPR_in_expr3604 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_68_in_expr3608 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3612 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_UNARY_EXPR_in_expr3638 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_67_in_expr3642 = new BitSet(new long[]{0xE000000000070450L,0x0000000000000FFFL});
    public static final BitSet FOLLOW_expr_in_expr3646 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_value_in_expr3671 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_opCall_in_expr3704 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_INT_in_value3734 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Cstring_in_value3768 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_73_in_value3801 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_74_in_value3807 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_variableRef_in_value3833 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_functionInstance_in_value3863 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_configurationOps_in_opCall3901 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_createOp_in_configurationOps3920 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_75_in_createOp3943 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_componentType_in_createOp3945 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_id_in_componentType3979 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_id4000 = new BitSet(new long[]{0x0000000000000002L});

}